From 09e125e4589859e9632f56fccb277d38db29294d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 6 Oct 2022 18:31:06 +0000 Subject: [PATCH] CodeGen from PR 21025 in Azure/azure-rest-api-specs Sasolank/more review comments (#21025) * XML * proxy to gateway --- .../azure-mgmt-apimanagement/_meta.json | 10 +- .../azure/mgmt/apimanagement/__init__.py | 16 +- .../apimanagement/_api_management_client.py | 372 +- .../mgmt/apimanagement/_configuration.py | 50 +- .../azure/mgmt/apimanagement/_metadata.json | 206 - .../azure/mgmt/apimanagement/_patch.py | 2 +- .../mgmt/apimanagement/_serialization.py | 1970 +++ .../azure/mgmt/apimanagement/_vendor.py | 26 +- .../azure/mgmt/apimanagement/_version.py | 2 +- .../azure/mgmt/apimanagement/aio/__init__.py | 16 +- .../aio/_api_management_client.py | 373 +- .../mgmt/apimanagement/aio/_configuration.py | 52 +- .../azure/mgmt/apimanagement/aio/_patch.py | 2 +- .../azure/mgmt/apimanagement/aio/_vendor.py | 28 + .../apimanagement/aio/operations/__init__.py | 158 +- .../operations/_api_diagnostic_operations.py | 592 +- .../aio/operations/_api_export_operations.py | 108 +- .../_api_issue_attachment_operations.py | 456 +- .../_api_issue_comment_operations.py | 452 +- .../aio/operations/_api_issue_operations.py | 588 +- .../_api_management_client_operations.py | 215 +- .../_api_management_operations_operations.py | 106 +- .../_api_management_service_operations.py | 1483 ++- ..._api_management_service_skus_operations.py | 114 +- .../_api_management_skus_operations.py | 107 +- .../operations/_api_operation_operations.py | 600 +- .../_api_operation_policy_operations.py | 446 +- .../aio/operations/_api_operations.py | 720 +- .../aio/operations/_api_policy_operations.py | 435 +- .../aio/operations/_api_product_operations.py | 121 +- .../aio/operations/_api_release_operations.py | 593 +- .../operations/_api_revision_operations.py | 122 +- .../aio/operations/_api_schema_operations.py | 518 +- .../_api_tag_description_operations.py | 440 +- .../operations/_api_version_set_operations.py | 565 +- .../_authorization_server_operations.py | 618 +- .../aio/operations/_backend_operations.py | 695 +- .../aio/operations/_cache_operations.py | 563 +- .../aio/operations/_certificate_operations.py | 484 +- .../operations/_content_item_operations.py | 341 +- .../operations/_content_type_operations.py | 284 +- .../_delegation_settings_operations.py | 453 +- .../_deleted_services_operations.py | 269 +- .../aio/operations/_diagnostic_operations.py | 566 +- .../operations/_email_template_operations.py | 618 +- .../aio/operations/_gateway_api_operations.py | 368 +- ...ateway_certificate_authority_operations.py | 441 +- ...teway_hostname_configuration_operations.py | 450 +- .../aio/operations/_gateway_operations.py | 867 +- .../operations/_global_schema_operations.py | 505 +- .../aio/operations/_group_operations.py | 566 +- .../aio/operations/_group_user_operations.py | 281 +- .../_identity_provider_operations.py | 620 +- .../aio/operations/_issue_operations.py | 171 +- .../aio/operations/_logger_operations.py | 562 +- .../aio/operations/_named_value_operations.py | 886 +- .../operations/_network_status_operations.py | 154 +- .../operations/_notification_operations.py | 228 +- ...notification_recipient_email_operations.py | 266 +- ..._notification_recipient_user_operations.py | 263 +- .../_open_id_connect_provider_operations.py | 617 +- .../aio/operations/_operation_operations.py | 125 +- ...twork_dependencies_endpoints_operations.py | 100 +- .../apimanagement/aio/operations/_patch.py | 20 + .../_policy_description_operations.py | 100 +- .../aio/operations/_policy_operations.py | 412 +- .../operations/_portal_revision_operations.py | 650 +- .../operations/_portal_settings_operations.py | 98 +- ..._private_endpoint_connection_operations.py | 583 +- .../aio/operations/_product_api_operations.py | 284 +- .../operations/_product_group_operations.py | 284 +- .../aio/operations/_product_operations.py | 640 +- .../operations/_product_policy_operations.py | 427 +- .../_product_subscriptions_operations.py | 121 +- .../_quota_by_counter_keys_operations.py | 230 +- .../_quota_by_period_keys_operations.py | 241 +- .../aio/operations/_region_operations.py | 115 +- .../aio/operations/_reports_operations.py | 643 +- .../_sign_in_settings_operations.py | 403 +- .../_sign_up_settings_operations.py | 403 +- .../operations/_subscription_operations.py | 789 +- .../aio/operations/_tag_operations.py | 1460 ++- .../operations/_tag_resource_operations.py | 119 +- .../_tenant_access_git_operations.py | 160 +- .../operations/_tenant_access_operations.py | 694 +- .../_tenant_configuration_operations.py | 736 +- .../operations/_tenant_settings_operations.py | 171 +- .../_user_confirmation_password_operations.py | 95 +- .../aio/operations/_user_group_operations.py | 120 +- .../operations/_user_identities_operations.py | 117 +- .../aio/operations/_user_operations.py | 756 +- .../_user_subscription_operations.py | 175 +- .../mgmt/apimanagement/models/__init__.py | 876 +- .../models/_api_management_client_enums.py | 365 +- .../mgmt/apimanagement/models/_models_py3.py | 10910 ++++++++-------- .../azure/mgmt/apimanagement/models/_patch.py | 20 + .../mgmt/apimanagement/operations/__init__.py | 158 +- .../operations/_api_diagnostic_operations.py | 922 +- .../operations/_api_export_operations.py | 172 +- .../_api_issue_attachment_operations.py | 736 +- .../_api_issue_comment_operations.py | 732 +- .../operations/_api_issue_operations.py | 919 +- .../_api_management_client_operations.py | 276 +- .../_api_management_operations_operations.py | 146 +- .../_api_management_service_operations.py | 2117 +-- ..._api_management_service_skus_operations.py | 174 +- .../_api_management_skus_operations.py | 153 +- .../operations/_api_operation_operations.py | 922 +- .../_api_operation_policy_operations.py | 719 +- .../operations/_api_operations.py | 1091 +- .../operations/_api_policy_operations.py | 702 +- .../operations/_api_product_operations.py | 184 +- .../operations/_api_release_operations.py | 923 +- .../operations/_api_revision_operations.py | 185 +- .../operations/_api_schema_operations.py | 787 +- .../_api_tag_description_operations.py | 700 +- .../operations/_api_version_set_operations.py | 883 +- .../_authorization_server_operations.py | 989 +- .../operations/_backend_operations.py | 1074 +- .../operations/_cache_operations.py | 883 +- .../operations/_certificate_operations.py | 803 +- .../operations/_content_item_operations.py | 585 +- .../operations/_content_type_operations.py | 480 +- .../_delegation_settings_operations.py | 723 +- .../_deleted_services_operations.py | 408 +- .../operations/_diagnostic_operations.py | 884 +- .../operations/_email_template_operations.py | 922 +- .../operations/_gateway_api_operations.py | 593 +- ...ateway_certificate_authority_operations.py | 701 +- ...teway_hostname_configuration_operations.py | 716 +- .../operations/_gateway_operations.py | 1352 +- .../operations/_global_schema_operations.py | 766 +- .../operations/_group_operations.py | 888 +- .../operations/_group_user_operations.py | 497 +- .../_identity_provider_operations.py | 968 +- .../operations/_issue_operations.py | 285 +- .../operations/_logger_operations.py | 883 +- .../operations/_named_value_operations.py | 1316 +- .../operations/_network_status_operations.py | 263 +- .../operations/_notification_operations.py | 376 +- ...notification_recipient_email_operations.py | 461 +- ..._notification_recipient_user_operations.py | 458 +- .../_open_id_connect_provider_operations.py | 988 +- .../operations/_operation_operations.py | 192 +- ...twork_dependencies_endpoints_operations.py | 159 +- .../mgmt/apimanagement/operations/_patch.py | 20 + .../_policy_description_operations.py | 158 +- .../operations/_policy_operations.py | 663 +- .../operations/_portal_revision_operations.py | 924 +- .../operations/_portal_settings_operations.py | 157 +- ..._private_endpoint_connection_operations.py | 882 +- .../operations/_product_api_operations.py | 500 +- .../operations/_product_group_operations.py | 500 +- .../operations/_product_operations.py | 1011 +- .../operations/_product_policy_operations.py | 689 +- .../_product_subscriptions_operations.py | 184 +- .../_quota_by_counter_keys_operations.py | 353 +- .../_quota_by_period_keys_operations.py | 356 +- .../operations/_region_operations.py | 174 +- .../operations/_reports_operations.py | 1037 +- .../_sign_in_settings_operations.py | 627 +- .../_sign_up_settings_operations.py | 627 +- .../operations/_subscription_operations.py | 1262 +- .../operations/_tag_operations.py | 2537 ++-- .../operations/_tag_resource_operations.py | 180 +- .../_tenant_access_git_operations.py | 259 +- .../operations/_tenant_access_operations.py | 1090 +- .../_tenant_configuration_operations.py | 950 +- .../operations/_tenant_settings_operations.py | 282 +- .../_user_confirmation_password_operations.py | 157 +- .../operations/_user_group_operations.py | 183 +- .../operations/_user_identities_operations.py | 180 +- .../operations/_user_operations.py | 1188 +- .../_user_subscription_operations.py | 292 +- 174 files changed, 61583 insertions(+), 36695 deletions(-) delete mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json index 1208e022ae8a1..3ce68b474b9fa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json +++ b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.12.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.1.9", + "@autorest/modelerfour@4.24.3" ], - "commit": "0b70eafc6469141d5c4dc868c4a4438db6c32ead", + "commit": "318bfb17fafd255a121844b7e71a1087ec00875a", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/apimanagement/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/apimanagement/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.9 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/apimanagement/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py index 80f492a921b4f..5e027a355b47b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ApiManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ApiManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py index 076c212079e52..43857dfb3d7fb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py @@ -7,192 +7,279 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import ApiManagementClientConfiguration -from .operations import ApiDiagnosticOperations, ApiExportOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, ApiManagementClientOperationsMixin, ApiManagementOperationsOperations, ApiManagementServiceOperations, ApiManagementServiceSkusOperations, ApiManagementSkusOperations, ApiOperationOperations, ApiOperationPolicyOperations, ApiOperations, ApiPolicyOperations, ApiProductOperations, ApiReleaseOperations, ApiRevisionOperations, ApiSchemaOperations, ApiTagDescriptionOperations, ApiVersionSetOperations, AuthorizationServerOperations, BackendOperations, CacheOperations, CertificateOperations, ContentItemOperations, ContentTypeOperations, DelegationSettingsOperations, DeletedServicesOperations, DiagnosticOperations, EmailTemplateOperations, GatewayApiOperations, GatewayCertificateAuthorityOperations, GatewayHostnameConfigurationOperations, GatewayOperations, GlobalSchemaOperations, GroupOperations, GroupUserOperations, IdentityProviderOperations, IssueOperations, LoggerOperations, NamedValueOperations, NetworkStatusOperations, NotificationOperations, NotificationRecipientEmailOperations, NotificationRecipientUserOperations, OpenIdConnectProviderOperations, OperationOperations, OutboundNetworkDependenciesEndpointsOperations, PolicyDescriptionOperations, PolicyOperations, PortalRevisionOperations, PortalSettingsOperations, PrivateEndpointConnectionOperations, ProductApiOperations, ProductGroupOperations, ProductOperations, ProductPolicyOperations, ProductSubscriptionsOperations, QuotaByCounterKeysOperations, QuotaByPeriodKeysOperations, RegionOperations, ReportsOperations, SignInSettingsOperations, SignUpSettingsOperations, SubscriptionOperations, TagOperations, TagResourceOperations, TenantAccessGitOperations, TenantAccessOperations, TenantConfigurationOperations, TenantSettingsOperations, UserConfirmationPasswordOperations, UserGroupOperations, UserIdentitiesOperations, UserOperations, UserSubscriptionOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + ApiDiagnosticOperations, + ApiExportOperations, + ApiIssueAttachmentOperations, + ApiIssueCommentOperations, + ApiIssueOperations, + ApiManagementClientOperationsMixin, + ApiManagementOperationsOperations, + ApiManagementServiceOperations, + ApiManagementServiceSkusOperations, + ApiManagementSkusOperations, + ApiOperationOperations, + ApiOperationPolicyOperations, + ApiOperations, + ApiPolicyOperations, + ApiProductOperations, + ApiReleaseOperations, + ApiRevisionOperations, + ApiSchemaOperations, + ApiTagDescriptionOperations, + ApiVersionSetOperations, + AuthorizationServerOperations, + BackendOperations, + CacheOperations, + CertificateOperations, + ContentItemOperations, + ContentTypeOperations, + DelegationSettingsOperations, + DeletedServicesOperations, + DiagnosticOperations, + EmailTemplateOperations, + GatewayApiOperations, + GatewayCertificateAuthorityOperations, + GatewayHostnameConfigurationOperations, + GatewayOperations, + GlobalSchemaOperations, + GroupOperations, + GroupUserOperations, + IdentityProviderOperations, + IssueOperations, + LoggerOperations, + NamedValueOperations, + NetworkStatusOperations, + NotificationOperations, + NotificationRecipientEmailOperations, + NotificationRecipientUserOperations, + OpenIdConnectProviderOperations, + OperationOperations, + OutboundNetworkDependenciesEndpointsOperations, + PolicyDescriptionOperations, + PolicyOperations, + PortalRevisionOperations, + PortalSettingsOperations, + PrivateEndpointConnectionOperations, + ProductApiOperations, + ProductGroupOperations, + ProductOperations, + ProductPolicyOperations, + ProductSubscriptionsOperations, + QuotaByCounterKeysOperations, + QuotaByPeriodKeysOperations, + RegionOperations, + ReportsOperations, + SignInSettingsOperations, + SignUpSettingsOperations, + SubscriptionOperations, + TagOperations, + TagResourceOperations, + TenantAccessGitOperations, + TenantAccessOperations, + TenantConfigurationOperations, + TenantSettingsOperations, + UserConfirmationPasswordOperations, + UserGroupOperations, + UserIdentitiesOperations, + UserOperations, + UserSubscriptionOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApiManagementClient(ApiManagementClientOperationsMixin): + +class ApiManagementClient( + ApiManagementClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ApiManagement Client. :ivar api: ApiOperations operations - :vartype api: api_management_client.operations.ApiOperations + :vartype api: azure.mgmt.apimanagement.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations - :vartype api_revision: api_management_client.operations.ApiRevisionOperations + :vartype api_revision: azure.mgmt.apimanagement.operations.ApiRevisionOperations :ivar api_release: ApiReleaseOperations operations - :vartype api_release: api_management_client.operations.ApiReleaseOperations + :vartype api_release: azure.mgmt.apimanagement.operations.ApiReleaseOperations :ivar api_operation: ApiOperationOperations operations - :vartype api_operation: api_management_client.operations.ApiOperationOperations + :vartype api_operation: azure.mgmt.apimanagement.operations.ApiOperationOperations :ivar api_operation_policy: ApiOperationPolicyOperations operations - :vartype api_operation_policy: api_management_client.operations.ApiOperationPolicyOperations + :vartype api_operation_policy: azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations :ivar tag: TagOperations operations - :vartype tag: api_management_client.operations.TagOperations + :vartype tag: azure.mgmt.apimanagement.operations.TagOperations :ivar api_product: ApiProductOperations operations - :vartype api_product: api_management_client.operations.ApiProductOperations + :vartype api_product: azure.mgmt.apimanagement.operations.ApiProductOperations :ivar api_policy: ApiPolicyOperations operations - :vartype api_policy: api_management_client.operations.ApiPolicyOperations + :vartype api_policy: azure.mgmt.apimanagement.operations.ApiPolicyOperations :ivar api_schema: ApiSchemaOperations operations - :vartype api_schema: api_management_client.operations.ApiSchemaOperations + :vartype api_schema: azure.mgmt.apimanagement.operations.ApiSchemaOperations :ivar api_diagnostic: ApiDiagnosticOperations operations - :vartype api_diagnostic: api_management_client.operations.ApiDiagnosticOperations + :vartype api_diagnostic: azure.mgmt.apimanagement.operations.ApiDiagnosticOperations :ivar api_issue: ApiIssueOperations operations - :vartype api_issue: api_management_client.operations.ApiIssueOperations + :vartype api_issue: azure.mgmt.apimanagement.operations.ApiIssueOperations :ivar api_issue_comment: ApiIssueCommentOperations operations - :vartype api_issue_comment: api_management_client.operations.ApiIssueCommentOperations + :vartype api_issue_comment: azure.mgmt.apimanagement.operations.ApiIssueCommentOperations :ivar api_issue_attachment: ApiIssueAttachmentOperations operations - :vartype api_issue_attachment: api_management_client.operations.ApiIssueAttachmentOperations + :vartype api_issue_attachment: azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations :ivar api_tag_description: ApiTagDescriptionOperations operations - :vartype api_tag_description: api_management_client.operations.ApiTagDescriptionOperations + :vartype api_tag_description: azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations :ivar operation: OperationOperations operations - :vartype operation: api_management_client.operations.OperationOperations + :vartype operation: azure.mgmt.apimanagement.operations.OperationOperations :ivar api_export: ApiExportOperations operations - :vartype api_export: api_management_client.operations.ApiExportOperations + :vartype api_export: azure.mgmt.apimanagement.operations.ApiExportOperations :ivar api_version_set: ApiVersionSetOperations operations - :vartype api_version_set: api_management_client.operations.ApiVersionSetOperations + :vartype api_version_set: azure.mgmt.apimanagement.operations.ApiVersionSetOperations :ivar authorization_server: AuthorizationServerOperations operations - :vartype authorization_server: api_management_client.operations.AuthorizationServerOperations + :vartype authorization_server: + azure.mgmt.apimanagement.operations.AuthorizationServerOperations :ivar backend: BackendOperations operations - :vartype backend: api_management_client.operations.BackendOperations + :vartype backend: azure.mgmt.apimanagement.operations.BackendOperations :ivar cache: CacheOperations operations - :vartype cache: api_management_client.operations.CacheOperations + :vartype cache: azure.mgmt.apimanagement.operations.CacheOperations :ivar certificate: CertificateOperations operations - :vartype certificate: api_management_client.operations.CertificateOperations + :vartype certificate: azure.mgmt.apimanagement.operations.CertificateOperations :ivar content_type: ContentTypeOperations operations - :vartype content_type: api_management_client.operations.ContentTypeOperations + :vartype content_type: azure.mgmt.apimanagement.operations.ContentTypeOperations :ivar content_item: ContentItemOperations operations - :vartype content_item: api_management_client.operations.ContentItemOperations + :vartype content_item: azure.mgmt.apimanagement.operations.ContentItemOperations :ivar deleted_services: DeletedServicesOperations operations - :vartype deleted_services: api_management_client.operations.DeletedServicesOperations + :vartype deleted_services: azure.mgmt.apimanagement.operations.DeletedServicesOperations :ivar api_management_operations: ApiManagementOperationsOperations operations :vartype api_management_operations: - api_management_client.operations.ApiManagementOperationsOperations + azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations :vartype api_management_service_skus: - api_management_client.operations.ApiManagementServiceSkusOperations + azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations :ivar api_management_service: ApiManagementServiceOperations operations :vartype api_management_service: - api_management_client.operations.ApiManagementServiceOperations + azure.mgmt.apimanagement.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations - :vartype diagnostic: api_management_client.operations.DiagnosticOperations + :vartype diagnostic: azure.mgmt.apimanagement.operations.DiagnosticOperations :ivar email_template: EmailTemplateOperations operations - :vartype email_template: api_management_client.operations.EmailTemplateOperations + :vartype email_template: azure.mgmt.apimanagement.operations.EmailTemplateOperations :ivar gateway: GatewayOperations operations - :vartype gateway: api_management_client.operations.GatewayOperations + :vartype gateway: azure.mgmt.apimanagement.operations.GatewayOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations :vartype gateway_hostname_configuration: - api_management_client.operations.GatewayHostnameConfigurationOperations + azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations :ivar gateway_api: GatewayApiOperations operations - :vartype gateway_api: api_management_client.operations.GatewayApiOperations + :vartype gateway_api: azure.mgmt.apimanagement.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: - api_management_client.operations.GatewayCertificateAuthorityOperations + azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations :ivar group: GroupOperations operations - :vartype group: api_management_client.operations.GroupOperations + :vartype group: azure.mgmt.apimanagement.operations.GroupOperations :ivar group_user: GroupUserOperations operations - :vartype group_user: api_management_client.operations.GroupUserOperations + :vartype group_user: azure.mgmt.apimanagement.operations.GroupUserOperations :ivar identity_provider: IdentityProviderOperations operations - :vartype identity_provider: api_management_client.operations.IdentityProviderOperations + :vartype identity_provider: azure.mgmt.apimanagement.operations.IdentityProviderOperations :ivar issue: IssueOperations operations - :vartype issue: api_management_client.operations.IssueOperations + :vartype issue: azure.mgmt.apimanagement.operations.IssueOperations :ivar logger: LoggerOperations operations - :vartype logger: api_management_client.operations.LoggerOperations + :vartype logger: azure.mgmt.apimanagement.operations.LoggerOperations :ivar named_value: NamedValueOperations operations - :vartype named_value: api_management_client.operations.NamedValueOperations + :vartype named_value: azure.mgmt.apimanagement.operations.NamedValueOperations :ivar network_status: NetworkStatusOperations operations - :vartype network_status: api_management_client.operations.NetworkStatusOperations + :vartype network_status: azure.mgmt.apimanagement.operations.NetworkStatusOperations :ivar notification: NotificationOperations operations - :vartype notification: api_management_client.operations.NotificationOperations + :vartype notification: azure.mgmt.apimanagement.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations :vartype notification_recipient_user: - api_management_client.operations.NotificationRecipientUserOperations + azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations :ivar notification_recipient_email: NotificationRecipientEmailOperations operations :vartype notification_recipient_email: - api_management_client.operations.NotificationRecipientEmailOperations + azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations :vartype open_id_connect_provider: - api_management_client.operations.OpenIdConnectProviderOperations + azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations operations :vartype outbound_network_dependencies_endpoints: - api_management_client.operations.OutboundNetworkDependenciesEndpointsOperations + azure.mgmt.apimanagement.operations.OutboundNetworkDependenciesEndpointsOperations :ivar policy: PolicyOperations operations - :vartype policy: api_management_client.operations.PolicyOperations + :vartype policy: azure.mgmt.apimanagement.operations.PolicyOperations :ivar policy_description: PolicyDescriptionOperations operations - :vartype policy_description: api_management_client.operations.PolicyDescriptionOperations + :vartype policy_description: azure.mgmt.apimanagement.operations.PolicyDescriptionOperations :ivar portal_revision: PortalRevisionOperations operations - :vartype portal_revision: api_management_client.operations.PortalRevisionOperations + :vartype portal_revision: azure.mgmt.apimanagement.operations.PortalRevisionOperations :ivar portal_settings: PortalSettingsOperations operations - :vartype portal_settings: api_management_client.operations.PortalSettingsOperations + :vartype portal_settings: azure.mgmt.apimanagement.operations.PortalSettingsOperations :ivar sign_in_settings: SignInSettingsOperations operations - :vartype sign_in_settings: api_management_client.operations.SignInSettingsOperations + :vartype sign_in_settings: azure.mgmt.apimanagement.operations.SignInSettingsOperations :ivar sign_up_settings: SignUpSettingsOperations operations - :vartype sign_up_settings: api_management_client.operations.SignUpSettingsOperations + :vartype sign_up_settings: azure.mgmt.apimanagement.operations.SignUpSettingsOperations :ivar delegation_settings: DelegationSettingsOperations operations - :vartype delegation_settings: api_management_client.operations.DelegationSettingsOperations + :vartype delegation_settings: azure.mgmt.apimanagement.operations.DelegationSettingsOperations :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations :vartype private_endpoint_connection: - api_management_client.operations.PrivateEndpointConnectionOperations + azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations :ivar product: ProductOperations operations - :vartype product: api_management_client.operations.ProductOperations + :vartype product: azure.mgmt.apimanagement.operations.ProductOperations :ivar product_api: ProductApiOperations operations - :vartype product_api: api_management_client.operations.ProductApiOperations + :vartype product_api: azure.mgmt.apimanagement.operations.ProductApiOperations :ivar product_group: ProductGroupOperations operations - :vartype product_group: api_management_client.operations.ProductGroupOperations + :vartype product_group: azure.mgmt.apimanagement.operations.ProductGroupOperations :ivar product_subscriptions: ProductSubscriptionsOperations operations - :vartype product_subscriptions: api_management_client.operations.ProductSubscriptionsOperations + :vartype product_subscriptions: + azure.mgmt.apimanagement.operations.ProductSubscriptionsOperations :ivar product_policy: ProductPolicyOperations operations - :vartype product_policy: api_management_client.operations.ProductPolicyOperations + :vartype product_policy: azure.mgmt.apimanagement.operations.ProductPolicyOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations - :vartype quota_by_counter_keys: api_management_client.operations.QuotaByCounterKeysOperations + :vartype quota_by_counter_keys: + azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations - :vartype quota_by_period_keys: api_management_client.operations.QuotaByPeriodKeysOperations + :vartype quota_by_period_keys: azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations :ivar region: RegionOperations operations - :vartype region: api_management_client.operations.RegionOperations + :vartype region: azure.mgmt.apimanagement.operations.RegionOperations :ivar reports: ReportsOperations operations - :vartype reports: api_management_client.operations.ReportsOperations + :vartype reports: azure.mgmt.apimanagement.operations.ReportsOperations :ivar global_schema: GlobalSchemaOperations operations - :vartype global_schema: api_management_client.operations.GlobalSchemaOperations + :vartype global_schema: azure.mgmt.apimanagement.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations - :vartype tenant_settings: api_management_client.operations.TenantSettingsOperations + :vartype tenant_settings: azure.mgmt.apimanagement.operations.TenantSettingsOperations :ivar api_management_skus: ApiManagementSkusOperations operations - :vartype api_management_skus: api_management_client.operations.ApiManagementSkusOperations + :vartype api_management_skus: azure.mgmt.apimanagement.operations.ApiManagementSkusOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: api_management_client.operations.SubscriptionOperations + :vartype subscription: azure.mgmt.apimanagement.operations.SubscriptionOperations :ivar tag_resource: TagResourceOperations operations - :vartype tag_resource: api_management_client.operations.TagResourceOperations + :vartype tag_resource: azure.mgmt.apimanagement.operations.TagResourceOperations :ivar tenant_access: TenantAccessOperations operations - :vartype tenant_access: api_management_client.operations.TenantAccessOperations + :vartype tenant_access: azure.mgmt.apimanagement.operations.TenantAccessOperations :ivar tenant_access_git: TenantAccessGitOperations operations - :vartype tenant_access_git: api_management_client.operations.TenantAccessGitOperations + :vartype tenant_access_git: azure.mgmt.apimanagement.operations.TenantAccessGitOperations :ivar tenant_configuration: TenantConfigurationOperations operations - :vartype tenant_configuration: api_management_client.operations.TenantConfigurationOperations + :vartype tenant_configuration: + azure.mgmt.apimanagement.operations.TenantConfigurationOperations :ivar user: UserOperations operations - :vartype user: api_management_client.operations.UserOperations + :vartype user: azure.mgmt.apimanagement.operations.UserOperations :ivar user_group: UserGroupOperations operations - :vartype user_group: api_management_client.operations.UserGroupOperations + :vartype user_group: azure.mgmt.apimanagement.operations.UserGroupOperations :ivar user_subscription: UserSubscriptionOperations operations - :vartype user_subscription: api_management_client.operations.UserSubscriptionOperations + :vartype user_subscription: azure.mgmt.apimanagement.operations.UserSubscriptionOperations :ivar user_identities: UserIdentitiesOperations operations - :vartype user_identities: api_management_client.operations.UserIdentitiesOperations + :vartype user_identities: azure.mgmt.apimanagement.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: - api_management_client.operations.UserConfirmationPasswordOperations - :param credential: Credential needed for the client to connect to Azure. + azure.mgmt.apimanagement.operations.UserConfirmationPasswordOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -204,7 +291,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ApiManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ApiManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -215,84 +304,133 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize) + self.api_operation_policy = ApiOperationPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.tag = TagOperations(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._client, self._config, self._serialize, self._deserialize) - self.api_issue_attachment = ApiIssueAttachmentOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_tag_description = ApiTagDescriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_issue_comment = ApiIssueCommentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_issue_attachment = ApiIssueAttachmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_tag_description = ApiTagDescriptionOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) self.api_export = ApiExportOperations(self._client, self._config, self._serialize, self._deserialize) self.api_version_set = ApiVersionSetOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_server = AuthorizationServerOperations(self._client, self._config, self._serialize, self._deserialize) + self.authorization_server = AuthorizationServerOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.backend = BackendOperations(self._client, self._config, self._serialize, self._deserialize) self.cache = CacheOperations(self._client, self._config, self._serialize, self._deserialize) self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) 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.api_management_operations = ApiManagementOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_service_skus = ApiManagementServiceSkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_service = ApiManagementServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_services = DeletedServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_operations = ApiManagementOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_service_skus = ApiManagementServiceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_service = ApiManagementServiceOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.diagnostic = DiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) self.email_template = EmailTemplateOperations(self._client, self._config, self._serialize, self._deserialize) self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.identity_provider = IdentityProviderOperations( + 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._client, self._config, self._serialize, self._deserialize) - self.notification_recipient_email = NotificationRecipientEmailOperations(self._client, self._config, self._serialize, self._deserialize) - self.open_id_connect_provider = OpenIdConnectProviderOperations(self._client, self._config, self._serialize, self._deserialize) - self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification_recipient_user = NotificationRecipientUserOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.notification_recipient_email = NotificationRecipientEmailOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.open_id_connect_provider = OpenIdConnectProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_description = PolicyDescriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_description = PolicyDescriptionOperations( + 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._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connection = PrivateEndpointConnectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.delegation_settings = DelegationSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connection = PrivateEndpointConnectionOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.product_subscriptions = ProductSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.product_policy = ProductPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota_by_counter_keys = QuotaByCounterKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota_by_period_keys = QuotaByPeriodKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota_by_counter_keys = QuotaByCounterKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_by_period_keys = QuotaByPeriodKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) 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.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.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.tenant_configuration = TenantConfigurationOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_access_git = TenantAccessGitOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenant_configuration = TenantConfigurationOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.user_subscription = UserSubscriptionOperations( + 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.user_confirmation_password = UserConfirmationPasswordOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -301,7 +439,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 6644ed21cee1b..cf115d63c7117 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py @@ -19,25 +19,26 @@ from azure.core.credentials import TokenCredential -class ApiManagementClientConfiguration(Configuration): +class ApiManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ApiManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ApiManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-08-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +46,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-08-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-apimanagement/{}'.format(VERSION)) + 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)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json deleted file mode 100644 index 4d4ecf9095d35..0000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "chosen_version": "2021-08-01", - "total_api_version_list": ["2021-08-01"], - "client": { - "name": "ApiManagementClient", - "filename": "_api_management_client", - "description": "ApiManagement Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApiManagementClientConfiguration\"], \"._operations_mixin\": [\"ApiManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApiManagementClientConfiguration\"], \"._operations_mixin\": [\"ApiManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "api": "ApiOperations", - "api_revision": "ApiRevisionOperations", - "api_release": "ApiReleaseOperations", - "api_operation": "ApiOperationOperations", - "api_operation_policy": "ApiOperationPolicyOperations", - "tag": "TagOperations", - "api_product": "ApiProductOperations", - "api_policy": "ApiPolicyOperations", - "api_schema": "ApiSchemaOperations", - "api_diagnostic": "ApiDiagnosticOperations", - "api_issue": "ApiIssueOperations", - "api_issue_comment": "ApiIssueCommentOperations", - "api_issue_attachment": "ApiIssueAttachmentOperations", - "api_tag_description": "ApiTagDescriptionOperations", - "operation": "OperationOperations", - "api_export": "ApiExportOperations", - "api_version_set": "ApiVersionSetOperations", - "authorization_server": "AuthorizationServerOperations", - "backend": "BackendOperations", - "cache": "CacheOperations", - "certificate": "CertificateOperations", - "content_type": "ContentTypeOperations", - "content_item": "ContentItemOperations", - "deleted_services": "DeletedServicesOperations", - "api_management_operations": "ApiManagementOperationsOperations", - "api_management_service_skus": "ApiManagementServiceSkusOperations", - "api_management_service": "ApiManagementServiceOperations", - "diagnostic": "DiagnosticOperations", - "email_template": "EmailTemplateOperations", - "gateway": "GatewayOperations", - "gateway_hostname_configuration": "GatewayHostnameConfigurationOperations", - "gateway_api": "GatewayApiOperations", - "gateway_certificate_authority": "GatewayCertificateAuthorityOperations", - "group": "GroupOperations", - "group_user": "GroupUserOperations", - "identity_provider": "IdentityProviderOperations", - "issue": "IssueOperations", - "logger": "LoggerOperations", - "named_value": "NamedValueOperations", - "network_status": "NetworkStatusOperations", - "notification": "NotificationOperations", - "notification_recipient_user": "NotificationRecipientUserOperations", - "notification_recipient_email": "NotificationRecipientEmailOperations", - "open_id_connect_provider": "OpenIdConnectProviderOperations", - "outbound_network_dependencies_endpoints": "OutboundNetworkDependenciesEndpointsOperations", - "policy": "PolicyOperations", - "policy_description": "PolicyDescriptionOperations", - "portal_revision": "PortalRevisionOperations", - "portal_settings": "PortalSettingsOperations", - "sign_in_settings": "SignInSettingsOperations", - "sign_up_settings": "SignUpSettingsOperations", - "delegation_settings": "DelegationSettingsOperations", - "private_endpoint_connection": "PrivateEndpointConnectionOperations", - "product": "ProductOperations", - "product_api": "ProductApiOperations", - "product_group": "ProductGroupOperations", - "product_subscriptions": "ProductSubscriptionsOperations", - "product_policy": "ProductPolicyOperations", - "quota_by_counter_keys": "QuotaByCounterKeysOperations", - "quota_by_period_keys": "QuotaByPeriodKeysOperations", - "region": "RegionOperations", - "reports": "ReportsOperations", - "global_schema": "GlobalSchemaOperations", - "tenant_settings": "TenantSettingsOperations", - "api_management_skus": "ApiManagementSkusOperations", - "subscription": "SubscriptionOperations", - "tag_resource": "TagResourceOperations", - "tenant_access": "TenantAccessOperations", - "tenant_access_git": "TenantAccessGitOperations", - "tenant_configuration": "TenantConfigurationOperations", - "user": "UserOperations", - "user_group": "UserGroupOperations", - "user_subscription": "UserSubscriptionOperations", - "user_identities": "UserIdentitiesOperations", - "user_confirmation_password": "UserConfirmationPasswordOperations" - }, - "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"]}}}", - "operations": { - "_perform_connectivity_check_async_initial" : { - "sync": { - "signature": "def _perform_connectivity_check_async_initial(\n self,\n resource_group_name, # type: str\n service_name, # type: str\n connectivity_check_request_params, # type: \"_models.ConnectivityCheckRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.ConnectivityCheckResponse\"]\n", - "doc": "\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ConnectivityCheckResponse, or the result of cls(response)\n:rtype: ~api_management_client.models.ConnectivityCheckResponse or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def _perform_connectivity_check_async_initial(\n self,\n resource_group_name: str,\n service_name: str,\n connectivity_check_request_params: \"_models.ConnectivityCheckRequest\",\n **kwargs: Any\n) -\u003e Optional[\"_models.ConnectivityCheckResponse\"]:\n", - "doc": "\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ConnectivityCheckResponse, or the result of cls(response)\n:rtype: ~api_management_client.models.ConnectivityCheckResponse or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_group_name, service_name, connectivity_check_request_params" - }, - "begin_perform_connectivity_check_async" : { - "sync": { - "signature": "def begin_perform_connectivity_check_async(\n self,\n resource_group_name, # type: str\n service_name, # type: str\n connectivity_check_request_params, # type: \"_models.ConnectivityCheckRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.ConnectivityCheckResponse\"]\n", - "doc": "\"\"\"Performs a connectivity check between the API Management service and a given destination, and\nreturns metrics for the connection, as well as errors encountered while trying to establish it.\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either ConnectivityCheckResponse or the result\n of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~api_management_client.models.ConnectivityCheckResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def begin_perform_connectivity_check_async(\n self,\n resource_group_name: str,\n service_name: str,\n connectivity_check_request_params: \"_models.ConnectivityCheckRequest\",\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.ConnectivityCheckResponse\"]:\n", - "doc": "\"\"\"Performs a connectivity check between the API Management service and a given destination, and\nreturns metrics for the connection, as well as errors encountered while trying to establish it.\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either ConnectivityCheckResponse or the\n result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ConnectivityCheckResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_group_name, service_name, connectivity_check_request_params" - } - } - } -} \ No newline at end of file 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 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py @@ -28,4 +28,4 @@ # 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 \ No newline at end of file + pass diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py new file mode 100644 index 0000000000000..7c1dedb5133d3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +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.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +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): + 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 # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param 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. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param 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 + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param 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 + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param 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 + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param 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 + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **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__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + 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 + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # 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( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + 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}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :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. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.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") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py index 138f663c53a4e..b697c71bd3ecb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import ApiManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(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 cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.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 bed0fab90ba8a..5d66ce34ab770 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 @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._api_management_client import ApiManagementClient -__all__ = ['ApiManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ApiManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py index 7d65b6a09b3fb..17e8578d58ca7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py @@ -7,198 +7,286 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import ApiManagementClientConfiguration -from .operations import ApiDiagnosticOperations, ApiExportOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, ApiManagementClientOperationsMixin, ApiManagementOperationsOperations, ApiManagementServiceOperations, ApiManagementServiceSkusOperations, ApiManagementSkusOperations, ApiOperationOperations, ApiOperationPolicyOperations, ApiOperations, ApiPolicyOperations, ApiProductOperations, ApiReleaseOperations, ApiRevisionOperations, ApiSchemaOperations, ApiTagDescriptionOperations, ApiVersionSetOperations, AuthorizationServerOperations, BackendOperations, CacheOperations, CertificateOperations, ContentItemOperations, ContentTypeOperations, DelegationSettingsOperations, DeletedServicesOperations, DiagnosticOperations, EmailTemplateOperations, GatewayApiOperations, GatewayCertificateAuthorityOperations, GatewayHostnameConfigurationOperations, GatewayOperations, GlobalSchemaOperations, GroupOperations, GroupUserOperations, IdentityProviderOperations, IssueOperations, LoggerOperations, NamedValueOperations, NetworkStatusOperations, NotificationOperations, NotificationRecipientEmailOperations, NotificationRecipientUserOperations, OpenIdConnectProviderOperations, OperationOperations, OutboundNetworkDependenciesEndpointsOperations, PolicyDescriptionOperations, PolicyOperations, PortalRevisionOperations, PortalSettingsOperations, PrivateEndpointConnectionOperations, ProductApiOperations, ProductGroupOperations, ProductOperations, ProductPolicyOperations, ProductSubscriptionsOperations, QuotaByCounterKeysOperations, QuotaByPeriodKeysOperations, RegionOperations, ReportsOperations, SignInSettingsOperations, SignUpSettingsOperations, SubscriptionOperations, TagOperations, TagResourceOperations, TenantAccessGitOperations, TenantAccessOperations, TenantConfigurationOperations, TenantSettingsOperations, UserConfirmationPasswordOperations, UserGroupOperations, UserIdentitiesOperations, UserOperations, UserSubscriptionOperations +from .operations import ( + ApiDiagnosticOperations, + ApiExportOperations, + ApiIssueAttachmentOperations, + ApiIssueCommentOperations, + ApiIssueOperations, + ApiManagementClientOperationsMixin, + ApiManagementOperationsOperations, + ApiManagementServiceOperations, + ApiManagementServiceSkusOperations, + ApiManagementSkusOperations, + ApiOperationOperations, + ApiOperationPolicyOperations, + ApiOperations, + ApiPolicyOperations, + ApiProductOperations, + ApiReleaseOperations, + ApiRevisionOperations, + ApiSchemaOperations, + ApiTagDescriptionOperations, + ApiVersionSetOperations, + AuthorizationServerOperations, + BackendOperations, + CacheOperations, + CertificateOperations, + ContentItemOperations, + ContentTypeOperations, + DelegationSettingsOperations, + DeletedServicesOperations, + DiagnosticOperations, + EmailTemplateOperations, + GatewayApiOperations, + GatewayCertificateAuthorityOperations, + GatewayHostnameConfigurationOperations, + GatewayOperations, + GlobalSchemaOperations, + GroupOperations, + GroupUserOperations, + IdentityProviderOperations, + IssueOperations, + LoggerOperations, + NamedValueOperations, + NetworkStatusOperations, + NotificationOperations, + NotificationRecipientEmailOperations, + NotificationRecipientUserOperations, + OpenIdConnectProviderOperations, + OperationOperations, + OutboundNetworkDependenciesEndpointsOperations, + PolicyDescriptionOperations, + PolicyOperations, + PortalRevisionOperations, + PortalSettingsOperations, + PrivateEndpointConnectionOperations, + ProductApiOperations, + ProductGroupOperations, + ProductOperations, + ProductPolicyOperations, + ProductSubscriptionsOperations, + QuotaByCounterKeysOperations, + QuotaByPeriodKeysOperations, + RegionOperations, + ReportsOperations, + SignInSettingsOperations, + SignUpSettingsOperations, + SubscriptionOperations, + TagOperations, + TagResourceOperations, + TenantAccessGitOperations, + TenantAccessOperations, + TenantConfigurationOperations, + TenantSettingsOperations, + UserConfirmationPasswordOperations, + UserGroupOperations, + UserIdentitiesOperations, + UserOperations, + UserSubscriptionOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApiManagementClient(ApiManagementClientOperationsMixin): + +class ApiManagementClient( + ApiManagementClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ApiManagement Client. :ivar api: ApiOperations operations - :vartype api: api_management_client.aio.operations.ApiOperations + :vartype api: azure.mgmt.apimanagement.aio.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations - :vartype api_revision: api_management_client.aio.operations.ApiRevisionOperations + :vartype api_revision: azure.mgmt.apimanagement.aio.operations.ApiRevisionOperations :ivar api_release: ApiReleaseOperations operations - :vartype api_release: api_management_client.aio.operations.ApiReleaseOperations + :vartype api_release: azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations :ivar api_operation: ApiOperationOperations operations - :vartype api_operation: api_management_client.aio.operations.ApiOperationOperations + :vartype api_operation: azure.mgmt.apimanagement.aio.operations.ApiOperationOperations :ivar api_operation_policy: ApiOperationPolicyOperations operations :vartype api_operation_policy: - api_management_client.aio.operations.ApiOperationPolicyOperations + azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations :ivar tag: TagOperations operations - :vartype tag: api_management_client.aio.operations.TagOperations + :vartype tag: azure.mgmt.apimanagement.aio.operations.TagOperations :ivar api_product: ApiProductOperations operations - :vartype api_product: api_management_client.aio.operations.ApiProductOperations + :vartype api_product: azure.mgmt.apimanagement.aio.operations.ApiProductOperations :ivar api_policy: ApiPolicyOperations operations - :vartype api_policy: api_management_client.aio.operations.ApiPolicyOperations + :vartype api_policy: azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations :ivar api_schema: ApiSchemaOperations operations - :vartype api_schema: api_management_client.aio.operations.ApiSchemaOperations + :vartype api_schema: azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations :ivar api_diagnostic: ApiDiagnosticOperations operations - :vartype api_diagnostic: api_management_client.aio.operations.ApiDiagnosticOperations + :vartype api_diagnostic: azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations :ivar api_issue: ApiIssueOperations operations - :vartype api_issue: api_management_client.aio.operations.ApiIssueOperations + :vartype api_issue: azure.mgmt.apimanagement.aio.operations.ApiIssueOperations :ivar api_issue_comment: ApiIssueCommentOperations operations - :vartype api_issue_comment: api_management_client.aio.operations.ApiIssueCommentOperations + :vartype api_issue_comment: azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations :ivar api_issue_attachment: ApiIssueAttachmentOperations operations :vartype api_issue_attachment: - api_management_client.aio.operations.ApiIssueAttachmentOperations + azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations :ivar api_tag_description: ApiTagDescriptionOperations operations - :vartype api_tag_description: api_management_client.aio.operations.ApiTagDescriptionOperations + :vartype api_tag_description: + azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations :ivar operation: OperationOperations operations - :vartype operation: api_management_client.aio.operations.OperationOperations + :vartype operation: azure.mgmt.apimanagement.aio.operations.OperationOperations :ivar api_export: ApiExportOperations operations - :vartype api_export: api_management_client.aio.operations.ApiExportOperations + :vartype api_export: azure.mgmt.apimanagement.aio.operations.ApiExportOperations :ivar api_version_set: ApiVersionSetOperations operations - :vartype api_version_set: api_management_client.aio.operations.ApiVersionSetOperations + :vartype api_version_set: azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations :ivar authorization_server: AuthorizationServerOperations operations :vartype authorization_server: - api_management_client.aio.operations.AuthorizationServerOperations + azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations :ivar backend: BackendOperations operations - :vartype backend: api_management_client.aio.operations.BackendOperations + :vartype backend: azure.mgmt.apimanagement.aio.operations.BackendOperations :ivar cache: CacheOperations operations - :vartype cache: api_management_client.aio.operations.CacheOperations + :vartype cache: azure.mgmt.apimanagement.aio.operations.CacheOperations :ivar certificate: CertificateOperations operations - :vartype certificate: api_management_client.aio.operations.CertificateOperations + :vartype certificate: azure.mgmt.apimanagement.aio.operations.CertificateOperations :ivar content_type: ContentTypeOperations operations - :vartype content_type: api_management_client.aio.operations.ContentTypeOperations + :vartype content_type: azure.mgmt.apimanagement.aio.operations.ContentTypeOperations :ivar content_item: ContentItemOperations operations - :vartype content_item: api_management_client.aio.operations.ContentItemOperations + :vartype content_item: azure.mgmt.apimanagement.aio.operations.ContentItemOperations :ivar deleted_services: DeletedServicesOperations operations - :vartype deleted_services: api_management_client.aio.operations.DeletedServicesOperations + :vartype deleted_services: azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations :ivar api_management_operations: ApiManagementOperationsOperations operations :vartype api_management_operations: - api_management_client.aio.operations.ApiManagementOperationsOperations + azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations :vartype api_management_service_skus: - api_management_client.aio.operations.ApiManagementServiceSkusOperations + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations :ivar api_management_service: ApiManagementServiceOperations operations :vartype api_management_service: - api_management_client.aio.operations.ApiManagementServiceOperations + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations - :vartype diagnostic: api_management_client.aio.operations.DiagnosticOperations + :vartype diagnostic: azure.mgmt.apimanagement.aio.operations.DiagnosticOperations :ivar email_template: EmailTemplateOperations operations - :vartype email_template: api_management_client.aio.operations.EmailTemplateOperations + :vartype email_template: azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations :ivar gateway: GatewayOperations operations - :vartype gateway: api_management_client.aio.operations.GatewayOperations + :vartype gateway: azure.mgmt.apimanagement.aio.operations.GatewayOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations :vartype gateway_hostname_configuration: - api_management_client.aio.operations.GatewayHostnameConfigurationOperations + azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations :ivar gateway_api: GatewayApiOperations operations - :vartype gateway_api: api_management_client.aio.operations.GatewayApiOperations + :vartype gateway_api: azure.mgmt.apimanagement.aio.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: - api_management_client.aio.operations.GatewayCertificateAuthorityOperations + azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations :ivar group: GroupOperations operations - :vartype group: api_management_client.aio.operations.GroupOperations + :vartype group: azure.mgmt.apimanagement.aio.operations.GroupOperations :ivar group_user: GroupUserOperations operations - :vartype group_user: api_management_client.aio.operations.GroupUserOperations + :vartype group_user: azure.mgmt.apimanagement.aio.operations.GroupUserOperations :ivar identity_provider: IdentityProviderOperations operations - :vartype identity_provider: api_management_client.aio.operations.IdentityProviderOperations + :vartype identity_provider: azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations :ivar issue: IssueOperations operations - :vartype issue: api_management_client.aio.operations.IssueOperations + :vartype issue: azure.mgmt.apimanagement.aio.operations.IssueOperations :ivar logger: LoggerOperations operations - :vartype logger: api_management_client.aio.operations.LoggerOperations + :vartype logger: azure.mgmt.apimanagement.aio.operations.LoggerOperations :ivar named_value: NamedValueOperations operations - :vartype named_value: api_management_client.aio.operations.NamedValueOperations + :vartype named_value: azure.mgmt.apimanagement.aio.operations.NamedValueOperations :ivar network_status: NetworkStatusOperations operations - :vartype network_status: api_management_client.aio.operations.NetworkStatusOperations + :vartype network_status: azure.mgmt.apimanagement.aio.operations.NetworkStatusOperations :ivar notification: NotificationOperations operations - :vartype notification: api_management_client.aio.operations.NotificationOperations + :vartype notification: azure.mgmt.apimanagement.aio.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations :vartype notification_recipient_user: - api_management_client.aio.operations.NotificationRecipientUserOperations + azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations :ivar notification_recipient_email: NotificationRecipientEmailOperations operations :vartype notification_recipient_email: - api_management_client.aio.operations.NotificationRecipientEmailOperations + azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations :vartype open_id_connect_provider: - api_management_client.aio.operations.OpenIdConnectProviderOperations + azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations operations :vartype outbound_network_dependencies_endpoints: - api_management_client.aio.operations.OutboundNetworkDependenciesEndpointsOperations + azure.mgmt.apimanagement.aio.operations.OutboundNetworkDependenciesEndpointsOperations :ivar policy: PolicyOperations operations - :vartype policy: api_management_client.aio.operations.PolicyOperations + :vartype policy: azure.mgmt.apimanagement.aio.operations.PolicyOperations :ivar policy_description: PolicyDescriptionOperations operations - :vartype policy_description: api_management_client.aio.operations.PolicyDescriptionOperations + :vartype policy_description: + azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations :ivar portal_revision: PortalRevisionOperations operations - :vartype portal_revision: api_management_client.aio.operations.PortalRevisionOperations + :vartype portal_revision: azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations :ivar portal_settings: PortalSettingsOperations operations - :vartype portal_settings: api_management_client.aio.operations.PortalSettingsOperations + :vartype portal_settings: azure.mgmt.apimanagement.aio.operations.PortalSettingsOperations :ivar sign_in_settings: SignInSettingsOperations operations - :vartype sign_in_settings: api_management_client.aio.operations.SignInSettingsOperations + :vartype sign_in_settings: azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations :ivar sign_up_settings: SignUpSettingsOperations operations - :vartype sign_up_settings: api_management_client.aio.operations.SignUpSettingsOperations + :vartype sign_up_settings: azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations :ivar delegation_settings: DelegationSettingsOperations operations - :vartype delegation_settings: api_management_client.aio.operations.DelegationSettingsOperations + :vartype delegation_settings: + azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations :vartype private_endpoint_connection: - api_management_client.aio.operations.PrivateEndpointConnectionOperations + azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations :ivar product: ProductOperations operations - :vartype product: api_management_client.aio.operations.ProductOperations + :vartype product: azure.mgmt.apimanagement.aio.operations.ProductOperations :ivar product_api: ProductApiOperations operations - :vartype product_api: api_management_client.aio.operations.ProductApiOperations + :vartype product_api: azure.mgmt.apimanagement.aio.operations.ProductApiOperations :ivar product_group: ProductGroupOperations operations - :vartype product_group: api_management_client.aio.operations.ProductGroupOperations + :vartype product_group: azure.mgmt.apimanagement.aio.operations.ProductGroupOperations :ivar product_subscriptions: ProductSubscriptionsOperations operations :vartype product_subscriptions: - api_management_client.aio.operations.ProductSubscriptionsOperations + azure.mgmt.apimanagement.aio.operations.ProductSubscriptionsOperations :ivar product_policy: ProductPolicyOperations operations - :vartype product_policy: api_management_client.aio.operations.ProductPolicyOperations + :vartype product_policy: azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations :vartype quota_by_counter_keys: - api_management_client.aio.operations.QuotaByCounterKeysOperations + azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations - :vartype quota_by_period_keys: api_management_client.aio.operations.QuotaByPeriodKeysOperations + :vartype quota_by_period_keys: + azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations :ivar region: RegionOperations operations - :vartype region: api_management_client.aio.operations.RegionOperations + :vartype region: azure.mgmt.apimanagement.aio.operations.RegionOperations :ivar reports: ReportsOperations operations - :vartype reports: api_management_client.aio.operations.ReportsOperations + :vartype reports: azure.mgmt.apimanagement.aio.operations.ReportsOperations :ivar global_schema: GlobalSchemaOperations operations - :vartype global_schema: api_management_client.aio.operations.GlobalSchemaOperations + :vartype global_schema: azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations - :vartype tenant_settings: api_management_client.aio.operations.TenantSettingsOperations + :vartype tenant_settings: azure.mgmt.apimanagement.aio.operations.TenantSettingsOperations :ivar api_management_skus: ApiManagementSkusOperations operations - :vartype api_management_skus: api_management_client.aio.operations.ApiManagementSkusOperations + :vartype api_management_skus: + azure.mgmt.apimanagement.aio.operations.ApiManagementSkusOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: api_management_client.aio.operations.SubscriptionOperations + :vartype subscription: azure.mgmt.apimanagement.aio.operations.SubscriptionOperations :ivar tag_resource: TagResourceOperations operations - :vartype tag_resource: api_management_client.aio.operations.TagResourceOperations + :vartype tag_resource: azure.mgmt.apimanagement.aio.operations.TagResourceOperations :ivar tenant_access: TenantAccessOperations operations - :vartype tenant_access: api_management_client.aio.operations.TenantAccessOperations + :vartype tenant_access: azure.mgmt.apimanagement.aio.operations.TenantAccessOperations :ivar tenant_access_git: TenantAccessGitOperations operations - :vartype tenant_access_git: api_management_client.aio.operations.TenantAccessGitOperations + :vartype tenant_access_git: azure.mgmt.apimanagement.aio.operations.TenantAccessGitOperations :ivar tenant_configuration: TenantConfigurationOperations operations :vartype tenant_configuration: - api_management_client.aio.operations.TenantConfigurationOperations + azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations :ivar user: UserOperations operations - :vartype user: api_management_client.aio.operations.UserOperations + :vartype user: azure.mgmt.apimanagement.aio.operations.UserOperations :ivar user_group: UserGroupOperations operations - :vartype user_group: api_management_client.aio.operations.UserGroupOperations + :vartype user_group: azure.mgmt.apimanagement.aio.operations.UserGroupOperations :ivar user_subscription: UserSubscriptionOperations operations - :vartype user_subscription: api_management_client.aio.operations.UserSubscriptionOperations + :vartype user_subscription: azure.mgmt.apimanagement.aio.operations.UserSubscriptionOperations :ivar user_identities: UserIdentitiesOperations operations - :vartype user_identities: api_management_client.aio.operations.UserIdentitiesOperations + :vartype user_identities: azure.mgmt.apimanagement.aio.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: - api_management_client.aio.operations.UserConfirmationPasswordOperations - :param credential: Credential needed for the client to connect to Azure. + azure.mgmt.apimanagement.aio.operations.UserConfirmationPasswordOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -210,7 +298,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ApiManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ApiManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -221,84 +311,133 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize) + self.api_operation_policy = ApiOperationPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.tag = TagOperations(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._client, self._config, self._serialize, self._deserialize) - self.api_issue_attachment = ApiIssueAttachmentOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_tag_description = ApiTagDescriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_issue_comment = ApiIssueCommentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_issue_attachment = ApiIssueAttachmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_tag_description = ApiTagDescriptionOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) self.api_export = ApiExportOperations(self._client, self._config, self._serialize, self._deserialize) self.api_version_set = ApiVersionSetOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_server = AuthorizationServerOperations(self._client, self._config, self._serialize, self._deserialize) + self.authorization_server = AuthorizationServerOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.backend = BackendOperations(self._client, self._config, self._serialize, self._deserialize) self.cache = CacheOperations(self._client, self._config, self._serialize, self._deserialize) self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) 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.api_management_operations = ApiManagementOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_service_skus = ApiManagementServiceSkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_service = ApiManagementServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_services = DeletedServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_operations = ApiManagementOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_service_skus = ApiManagementServiceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_service = ApiManagementServiceOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.diagnostic = DiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) self.email_template = EmailTemplateOperations(self._client, self._config, self._serialize, self._deserialize) self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.identity_provider = IdentityProviderOperations( + 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._client, self._config, self._serialize, self._deserialize) - self.notification_recipient_email = NotificationRecipientEmailOperations(self._client, self._config, self._serialize, self._deserialize) - self.open_id_connect_provider = OpenIdConnectProviderOperations(self._client, self._config, self._serialize, self._deserialize) - self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification_recipient_user = NotificationRecipientUserOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.notification_recipient_email = NotificationRecipientEmailOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.open_id_connect_provider = OpenIdConnectProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_description = PolicyDescriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_description = PolicyDescriptionOperations( + 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._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connection = PrivateEndpointConnectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.delegation_settings = DelegationSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connection = PrivateEndpointConnectionOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.product_subscriptions = ProductSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.product_policy = ProductPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota_by_counter_keys = QuotaByCounterKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota_by_period_keys = QuotaByPeriodKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota_by_counter_keys = QuotaByCounterKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_by_period_keys = QuotaByPeriodKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) 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.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.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.tenant_configuration = TenantConfigurationOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_access_git = TenantAccessGitOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenant_configuration = TenantConfigurationOperations( + 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._client, self._config, self._serialize, self._deserialize) + self.user_subscription = UserSubscriptionOperations( + 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.user_confirmation_password = UserConfirmationPasswordOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -307,7 +446,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 d049edf46f0ab..7d4e8a2fc20ef 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 @@ -19,25 +19,26 @@ from azure.core.credentials_async import AsyncTokenCredential -class ApiManagementClientConfiguration(Configuration): +class ApiManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ApiManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ApiManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-08-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +46,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-08-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-apimanagement/{}'.format(VERSION)) + 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)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) 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 74e48ecd07cf3..f99e77fef9861 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 @@ -28,4 +28,4 @@ # 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 \ No newline at end of file + pass 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 new file mode 100644 index 0000000000000..5d560022687f6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApiManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class MixinABC(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 9f8b6482fabbe..898ea8cdf5325 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 @@ -83,81 +83,87 @@ from ._user_identities_operations import UserIdentitiesOperations from ._user_confirmation_password_operations import UserConfirmationPasswordOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ApiOperations', - 'ApiRevisionOperations', - 'ApiReleaseOperations', - 'ApiOperationOperations', - 'ApiOperationPolicyOperations', - 'TagOperations', - 'ApiProductOperations', - 'ApiPolicyOperations', - 'ApiSchemaOperations', - 'ApiDiagnosticOperations', - 'ApiIssueOperations', - 'ApiIssueCommentOperations', - 'ApiIssueAttachmentOperations', - 'ApiTagDescriptionOperations', - 'OperationOperations', - 'ApiExportOperations', - 'ApiVersionSetOperations', - 'AuthorizationServerOperations', - 'BackendOperations', - 'CacheOperations', - 'CertificateOperations', - 'ApiManagementClientOperationsMixin', - 'ContentTypeOperations', - 'ContentItemOperations', - 'DeletedServicesOperations', - 'ApiManagementOperationsOperations', - 'ApiManagementServiceSkusOperations', - 'ApiManagementServiceOperations', - 'DiagnosticOperations', - 'EmailTemplateOperations', - 'GatewayOperations', - 'GatewayHostnameConfigurationOperations', - 'GatewayApiOperations', - 'GatewayCertificateAuthorityOperations', - 'GroupOperations', - 'GroupUserOperations', - 'IdentityProviderOperations', - 'IssueOperations', - 'LoggerOperations', - 'NamedValueOperations', - 'NetworkStatusOperations', - 'NotificationOperations', - 'NotificationRecipientUserOperations', - 'NotificationRecipientEmailOperations', - 'OpenIdConnectProviderOperations', - 'OutboundNetworkDependenciesEndpointsOperations', - 'PolicyOperations', - 'PolicyDescriptionOperations', - 'PortalRevisionOperations', - 'PortalSettingsOperations', - 'SignInSettingsOperations', - 'SignUpSettingsOperations', - 'DelegationSettingsOperations', - 'PrivateEndpointConnectionOperations', - 'ProductOperations', - 'ProductApiOperations', - 'ProductGroupOperations', - 'ProductSubscriptionsOperations', - 'ProductPolicyOperations', - 'QuotaByCounterKeysOperations', - 'QuotaByPeriodKeysOperations', - 'RegionOperations', - 'ReportsOperations', - 'GlobalSchemaOperations', - 'TenantSettingsOperations', - 'ApiManagementSkusOperations', - 'SubscriptionOperations', - 'TagResourceOperations', - 'TenantAccessOperations', - 'TenantAccessGitOperations', - 'TenantConfigurationOperations', - 'UserOperations', - 'UserGroupOperations', - 'UserSubscriptionOperations', - 'UserIdentitiesOperations', - 'UserConfirmationPasswordOperations', + "ApiOperations", + "ApiRevisionOperations", + "ApiReleaseOperations", + "ApiOperationOperations", + "ApiOperationPolicyOperations", + "TagOperations", + "ApiProductOperations", + "ApiPolicyOperations", + "ApiSchemaOperations", + "ApiDiagnosticOperations", + "ApiIssueOperations", + "ApiIssueCommentOperations", + "ApiIssueAttachmentOperations", + "ApiTagDescriptionOperations", + "OperationOperations", + "ApiExportOperations", + "ApiVersionSetOperations", + "AuthorizationServerOperations", + "BackendOperations", + "CacheOperations", + "CertificateOperations", + "ApiManagementClientOperationsMixin", + "ContentTypeOperations", + "ContentItemOperations", + "DeletedServicesOperations", + "ApiManagementOperationsOperations", + "ApiManagementServiceSkusOperations", + "ApiManagementServiceOperations", + "DiagnosticOperations", + "EmailTemplateOperations", + "GatewayOperations", + "GatewayHostnameConfigurationOperations", + "GatewayApiOperations", + "GatewayCertificateAuthorityOperations", + "GroupOperations", + "GroupUserOperations", + "IdentityProviderOperations", + "IssueOperations", + "LoggerOperations", + "NamedValueOperations", + "NetworkStatusOperations", + "NotificationOperations", + "NotificationRecipientUserOperations", + "NotificationRecipientEmailOperations", + "OpenIdConnectProviderOperations", + "OutboundNetworkDependenciesEndpointsOperations", + "PolicyOperations", + "PolicyDescriptionOperations", + "PortalRevisionOperations", + "PortalSettingsOperations", + "SignInSettingsOperations", + "SignUpSettingsOperations", + "DelegationSettingsOperations", + "PrivateEndpointConnectionOperations", + "ProductOperations", + "ProductApiOperations", + "ProductGroupOperations", + "ProductSubscriptionsOperations", + "ProductPolicyOperations", + "QuotaByCounterKeysOperations", + "QuotaByPeriodKeysOperations", + "RegionOperations", + "ReportsOperations", + "GlobalSchemaOperations", + "TenantSettingsOperations", + "ApiManagementSkusOperations", + "SubscriptionOperations", + "TagResourceOperations", + "TenantAccessOperations", + "TenantAccessGitOperations", + "TenantConfigurationOperations", + "UserOperations", + "UserGroupOperations", + "UserSubscriptionOperations", + "UserIdentitiesOperations", + "UserConfirmationPasswordOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py index 3f85283256974..35bae1d35511a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_diagnostic_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiDiagnosticOperations: - """ApiDiagnosticOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_diagnostic` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,38 +71,48 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DiagnosticCollection"]: + ) -> AsyncIterable["_models.DiagnosticContract"]: """Lists all diagnostics of an API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticCollection or the result of - cls(response) + :return: An iterator like instance of either DiagnosticContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.DiagnosticCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -96,25 +121,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +150,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,56 +162,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,60 +227,67 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - diagnostic_id: str, - **kwargs: Any - ) -> "_models.DiagnosticContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -258,17 +296,94 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -277,40 +392,57 @@ async def create_or_update( service_name: str, api_id: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic for an API or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - _json = self._serialize.body(parameters, 'DiagnosticContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -318,15 +450,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -336,22 +475,99 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -361,39 +577,56 @@ async def update( api_id: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Diagnostic Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DiagnosticContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, @@ -401,15 +634,22 @@ async def update( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,54 +658,55 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -473,12 +714,18 @@ async def delete( diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -489,5 +736,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # 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 index d6cc0ff9af643..be5c4d6b20b59 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_export_operations import build_get_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiExportOperations: - """ApiExportOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_export` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -50,37 +57,45 @@ async def get( resource_group_name: str, service_name: str, api_id: str, - format: Union[str, "_models.ExportFormat"], - export: Union[str, "_models.ExportApi"], + format: Union[str, _models.ExportFormat], + export: Union[str, _models.ExportApi], **kwargs: Any - ) -> "_models.ApiExportResult": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type format: str or ~api_management_client.models.ExportFormat - :param export: Query parameter required to export the API details. - :type export: str or ~api_management_client.models.ExportApi + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiExportResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiExportResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiExportResult] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -88,12 +103,18 @@ async def get( subscription_id=self._config.subscription_id, format=format, export=export, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,12 +122,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiExportResult', pipeline_response) + deserialized = self._deserialize("ApiExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py index f6d4d34929c91..c692fe4c17907 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_issue_attachment_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiIssueAttachmentOperations: - """ApiIssueAttachmentOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiIssueAttachmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,42 +71,53 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueAttachmentCollection"]: + ) -> AsyncIterable["_models.IssueAttachmentContract"]: """Lists all attachments for the Issue associated with the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueAttachmentCollection or the result of + :return: An iterator like instance of either IssueAttachmentContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueAttachmentCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueAttachmentCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -102,26 +127,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +156,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,49 +168,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + Issue. Required. :type attachment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, @@ -195,12 +218,18 @@ async def get_entity_tag( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,52 +238,52 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + Issue. Required. :type attachment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueAttachmentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueAttachmentContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -262,12 +291,18 @@ async def get( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -276,17 +311,102 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -296,43 +416,60 @@ async def create_or_update( api_id: str, issue_id: str, attachment_id: str, - parameters: "_models.IssueAttachmentContract", + parameters: Union[_models.IssueAttachmentContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueAttachmentContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + Issue. Required. :type attachment_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueAttachmentContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueAttachmentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueAttachmentContract] - _json = self._serialize.body(parameters, 'IssueAttachmentContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueAttachmentContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -341,15 +478,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -359,25 +503,24 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -389,33 +532,41 @@ async def delete( ) -> None: """Deletes the specified comment from an Issue. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -424,12 +575,18 @@ async def delete( attachment_id=attachment_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -440,5 +597,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # 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 index a47be54189f94..67abc6895314a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_issue_comment_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiIssueCommentOperations: - """ApiIssueCommentOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiIssueCommentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,42 +71,53 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueCommentCollection"]: + ) -> AsyncIterable["_models.IssueCommentContract"]: """Lists all comments for the Issue associated with the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueCommentCollection or the result of + :return: An iterator like instance of either IssueCommentContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueCommentCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCommentContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCommentCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -102,26 +127,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +156,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,48 +168,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, @@ -194,12 +218,18 @@ async def get_entity_tag( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -208,51 +238,52 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 callable cls: A custom type or function that will be passed the direct response - :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueCommentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCommentContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -260,12 +291,18 @@ async def get( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -274,17 +311,102 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueCommentContract', pipeline_response) + deserialized = self._deserialize("IssueCommentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -294,42 +416,60 @@ async def create_or_update( api_id: str, issue_id: str, comment_id: str, - parameters: "_models.IssueCommentContract", + parameters: Union[_models.IssueCommentContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueCommentContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. - :type parameters: ~api_management_client.models.IssueCommentContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueCommentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCommentContract] - _json = self._serialize.body(parameters, 'IssueCommentContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueCommentContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -338,15 +478,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -356,25 +503,24 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueCommentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueCommentContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueCommentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueCommentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -386,32 +532,41 @@ async def delete( ) -> None: """Deletes the specified comment from an Issue. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -420,12 +575,18 @@ async def delete( comment_id=comment_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -436,5 +597,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # 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 index 0f9ba2e907af2..8aa171fdfebff 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_issue_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiIssueOperations: - """ApiIssueOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiIssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_issue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,40 +72,50 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueCollection"]: + ) -> AsyncIterable["_models.IssueContract"]: """Lists all issues associated with the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + filter | eq | |
. Default value is None. :type filter: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -100,26 +125,22 @@ def prepare_request(next_link=None): expand_comments_attachments=expand_comments_attachments, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,7 +154,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,56 +166,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -201,15 +231,13 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace_async async def get( @@ -220,32 +248,40 @@ async def get( issue_id: str, expand_comments_attachments: Optional[bool] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -253,12 +289,18 @@ async def get( issue_id=issue_id, subscription_id=self._config.subscription_id, expand_comments_attachments=expand_comments_attachments, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,17 +309,94 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueContract', pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -286,40 +405,57 @@ async def create_or_update( service_name: str, api_id: str, issue_id: str, - parameters: "_models.IssueContract", + parameters: Union[_models.IssueContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Creates a new Issue for an API or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] - _json = self._serialize.body(parameters, 'IssueContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -327,15 +463,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -345,22 +488,99 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -370,39 +590,56 @@ async def update( api_id: str, issue_id: str, if_match: str, - parameters: "_models.IssueUpdateContract", + parameters: Union[_models.IssueUpdateContract, IO], **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Updates an existing issue for an API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IssueUpdateContract + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] - _json = self._serialize.body(parameters, 'IssueUpdateContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueUpdateContract") request = build_update_request( resource_group_name=resource_group_name, @@ -410,15 +647,22 @@ async def update( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,54 +671,55 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueContract', pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -482,12 +727,18 @@ async def delete( issue_id=issue_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -498,5 +749,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # 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 index 02126185a7f26..0ab73f68e3089 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,199 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_management_client_operations import build_perform_connectivity_check_async_request_initial -T = TypeVar('T') +from ...operations._api_management_client_operations import build_perform_connectivity_check_async_request +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiManagementClientOperationsMixin: +class ApiManagementClientOperationsMixin(MixinABC): async def _perform_connectivity_check_async_initial( self, resource_group_name: str, service_name: str, - connectivity_check_request_params: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO], **kwargs: Any - ) -> Optional["_models.ConnectivityCheckResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConnectivityCheckResponse"]] + ) -> Optional[_models.ConnectivityCheckResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ConnectivityCheckResponse]] - _json = self._serialize.body(connectivity_check_request_params, 'ConnectivityCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connectivity_check_request_params, (IO, bytes)): + _content = connectivity_check_request_params + else: + _json = self._serialize.body(connectivity_check_request_params, "ConnectivityCheckRequest") - request = build_perform_connectivity_check_async_request_initial( + 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, - template_url=self._perform_connectivity_check_async_initial.metadata['url'], + content=_content, + template_url=self._perform_connectivity_check_async_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ConnectivityCheckResponse', pipeline_response) + deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _perform_connectivity_check_async_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + _perform_connectivity_check_async_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectivityCheckResponse"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. - :type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest + :param connectivity_check_request_params: Connectivity Check request parameters. Is either a + model type or a IO type. Required. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -101,47 +210,53 @@ async def begin_perform_connectivity_check_async( :return: An instance of AsyncLROPoller that returns either ConnectivityCheckResponse or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ConnectivityCheckResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectivityCheckResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectivityCheckResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._perform_connectivity_check_async_initial( + raw_result = await self._perform_connectivity_check_async_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConnectivityCheckResponse', pipeline_response) + deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_perform_connectivity_check_async.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + begin_perform_connectivity_check_async.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py index 4956b9c0c9b0a..bd45a0d40ec7a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_operations_operations import build_list_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiManagementOperationsOperations: - """ApiManagementOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available REST API operations of the Microsoft.ApiManagement provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +109,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +121,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.ApiManagement/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ApiManagement/operations"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py index 7f87d5411907d..31e6d423a04ac 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,115 +6,237 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_management_service_operations import build_apply_network_configuration_updates_request_initial, build_backup_request_initial, build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_domain_ownership_identifier_request, build_get_request, build_get_sso_token_request, build_list_by_resource_group_request, build_list_request, build_restore_request_initial, build_update_request_initial -T = TypeVar('T') +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_restore_request, + build_update_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiManagementServiceOperations: - """ApiManagementServiceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - request = build_restore_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self._restore_initial.metadata['url'], + content=_content, + template_url=self._restore_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + _restore_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -125,115 +248,220 @@ async def begin_restore( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._restore_initial( + raw_result = await self._restore_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + begin_restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # type: ignore async def _backup_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - request = build_backup_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self._backup_initial.metadata['url'], + content=_content, + template_url=self._backup_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + _backup_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Parameters supplied to the ApiManagementService_Backup operation. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + :param parameters: Parameters supplied to the ApiManagementService_Backup operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -245,118 +473,224 @@ async def begin_backup( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._backup_initial( + raw_result = await self._backup_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + begin_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceResource", + parameters: Union[_models.ApiManagementServiceResource, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - _json = self._serialize.body(parameters, 'ApiManagementServiceResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementServiceResource") - request = build_create_or_update_request_initial( + 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, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceResource", + parameters: Union[_models.ApiManagementServiceResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.ApiManagementServiceResource + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -368,114 +702,216 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceUpdateParameters", + parameters: Union[_models.ApiManagementServiceUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - request = build_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceUpdateParameters", + parameters: Union[_models.ApiManagementServiceUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Updates an existing API Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.ApiManagementServiceUpdateParameters + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -487,86 +923,100 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ApiManagementServiceResource": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceResource, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -574,69 +1024,73 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + async def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing API Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -649,90 +1103,103 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApiManagementServiceListResult"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiManagementServiceListResult or the result of + :return: An iterator like instance of either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiManagementServiceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -746,7 +1213,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -756,49 +1225,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ApiManagementServiceListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ApiManagementServiceResource"]: """Lists all API Management services within an Azure subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiManagementServiceListResult or the result of + :return: An iterator like instance of either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiManagementServiceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -812,7 +1288,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -822,47 +1300,55 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace_async async def get_sso_token( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ApiManagementServiceGetSsoTokenResult": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceGetSsoTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetSsoTokenResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiManagementServiceGetSsoTokenResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetSsoTokenResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceGetSsoTokenResult] - request = build_get_sso_token_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_sso_token.metadata['url'], + api_version=api_version, + template_url=self.get_sso_token.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -870,52 +1356,112 @@ async def get_sso_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceGetSsoTokenResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceGetSsoTokenResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore + get_sso_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken"} # type: ignore - - @distributed_trace_async + @overload async def check_name_availability( self, - parameters: "_models.ApiManagementServiceCheckNameAvailabilityParameters", + parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ApiManagementServiceNameAvailabilityResult": + ) -> _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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, *, 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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], **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: """Checks availability and correctness of a name for an API Management service. - :param parameters: Parameters supplied to the CheckNameAvailability operation. + :param parameters: Parameters supplied to the CheckNameAvailability operation. Is either a + model type or a IO type. Required. :type parameters: - ~api_management_client.models.ApiManagementServiceCheckNameAvailabilityParameters + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceNameAvailabilityResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiManagementServiceNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceNameAvailabilityResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceNameAvailabilityResult] - _json = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -923,43 +1469,54 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability"} # type: ignore @distributed_trace_async async def get_domain_ownership_identifier( - self, - **kwargs: Any - ) -> "_models.ApiManagementServiceGetDomainOwnershipIdentifierResult": + self, **kwargs: Any + ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: """Get the custom domain ownership identifier for an API Management service. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceGetDomainOwnershipIdentifierResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetDomainOwnershipIdentifierResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiManagementServiceGetDomainOwnershipIdentifierResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetDomainOwnershipIdentifierResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceGetDomainOwnershipIdentifierResult] - request = build_get_domain_ownership_identifier_request( subscription_id=self._config.subscription_id, - template_url=self.get_domain_ownership_identifier.metadata['url'], + api_version=api_version, + template_url=self.get_domain_ownership_identifier.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -967,86 +1524,188 @@ async def get_domain_ownership_identifier( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceGetDomainOwnershipIdentifierResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_domain_ownership_identifier.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier'} # type: ignore - + get_domain_ownership_identifier.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier"} # type: ignore async def _apply_network_configuration_updates_initial( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO]] = None, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - if parameters is not None: - _json = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ApiManagementServiceApplyNetworkConfigurationParameters") + else: + _json = None - request = build_apply_network_configuration_updates_request_initial( + 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, - template_url=self._apply_network_configuration_updates_initial.metadata['url'], + content=_content, + template_url=self._apply_network_configuration_updates_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _apply_network_configuration_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + _apply_network_configuration_updates_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # type: ignore + @overload + async def begin_apply_network_configuration_updates( + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[IO] = 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + updated sequentially without incurring downtime in the region. Is either a model type or a IO + type. Default value is None. :type parameters: - ~api_management_client.models.ApiManagementServiceApplyNetworkConfigurationParameters + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1058,47 +1717,53 @@ async def begin_apply_network_configuration_updates( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._apply_network_configuration_updates_initial( + raw_result = await self._apply_network_configuration_updates_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_apply_network_configuration_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + begin_apply_network_configuration_updates.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # 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 index ffa3b8210fe29..10573492c4e2b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_service_skus_operations import build_list_available_service_skus_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiManagementServiceSkusOperations: - """ApiManagementServiceSkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementServiceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ResourceSkuResults"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuResults or the result of cls(response) + :return: An iterator like instance of either ResourceSkuResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ResourceSkuResults] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuResults"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuResults] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_available_service_skus.metadata['url'], + api_version=api_version, + template_url=self.list_available_service_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_available_service_skus_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -107,7 +121,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_available_service_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus'} # type: ignore + list_available_service_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py index b01df3ab7be65..068cc29c795be 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_skus_operations import build_list_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiManagementSkusOperations: - """ApiManagementSkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ApiManagementSkusResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ApiManagementSku"]: """Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiManagementSkusResult or the result of - cls(response) + :return: An iterator like instance of either ApiManagementSku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiManagementSkusResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementSkusResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementSkusResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +111,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,8 +123,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py index 395d994372777..33c00eda3c2ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_operation_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_api_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiOperationOperations: - """ApiOperationOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,15 +72,15 @@ def list_by_api( skip: Optional[int] = None, tags: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.OperationCollection"]: + ) -> AsyncIterable["_models.OperationContract"]: """Lists a collection of the operations for the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 | @@ -74,28 +89,37 @@ def list_by_api( |
| 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 |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :param tags: Include tags in the response. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationCollection or the result of cls(response) + :return: An iterator like instance of either OperationContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.OperationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -105,26 +129,22 @@ def prepare_request(next_link=None): top=top, skip=skip, tags=tags, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -138,7 +158,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,57 +170,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,61 +235,67 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - operation_id: str, - **kwargs: Any - ) -> "_models.OperationContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -270,17 +304,94 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OperationContract', pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -289,41 +400,57 @@ async def create_or_update( service_name: str, api_id: str, operation_id: str, - parameters: "_models.OperationContract", + parameters: Union[_models.OperationContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Creates a new operation in the API or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OperationContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationContract] - _json = self._serialize.body(parameters, 'OperationContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -331,15 +458,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -349,22 +483,99 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OperationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OperationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -374,40 +585,57 @@ async def update( api_id: str, operation_id: str, if_match: str, - parameters: "_models.OperationUpdateContract", + parameters: Union[_models.OperationUpdateContract, IO], **kwargs: Any - ) -> "_models.OperationContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: API Operation Update parameters. - :type parameters: ~api_management_client.models.OperationUpdateContract + :param parameters: API Operation Update parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'OperationUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationUpdateContract") request = build_update_request( resource_group_name=resource_group_name, @@ -415,15 +643,22 @@ async def update( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -432,55 +667,55 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OperationContract', pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -488,12 +723,18 @@ async def delete( operation_id=operation_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -504,5 +745,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # 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 index 7e64128059542..23ad3f6bc28b0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_operation_policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_operation_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiOperationPolicyOperations: - """ApiOperationPolicyOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiOperationPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - 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, - template_url=self.list_by_operation.metadata['url'], + api_version=api_version, + template_url=self.list_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,15 +117,14 @@ async def list_by_operation( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies'} # type: ignore - + list_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -113,35 +133,42 @@ async def get_entity_tag( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, @@ -149,12 +176,18 @@ async def get_entity_tag( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,15 +196,13 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace_async async def get( @@ -180,38 +211,46 @@ async def get( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API Operation level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -220,12 +259,18 @@ async def get( policy_id=policy_id, subscription_id=self._config.subscription_id, format=format, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -234,17 +279,100 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PolicyContract', pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -253,44 +381,60 @@ async def create_or_update( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API Operation level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - _json = self._serialize.body(parameters, 'PolicyContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -299,15 +443,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -317,63 +468,69 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async 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"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -382,12 +539,18 @@ async def delete( policy_id=policy_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -398,5 +561,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # 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 index 5ea1c9ae2f801..16a4900ed7394 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_by_tags_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiOperations: - """ApiOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -59,12 +75,12 @@ def list_by_service( tags: Optional[str] = None, expand_api_version_set: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollection"]: + ) -> AsyncIterable["_models.ApiContract"]: """Lists all APIs of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -73,29 +89,39 @@ def list_by_service( |
| 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 | |
. + startswith, endswith |
| isCurrent | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :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. + :param expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. :type expand_api_version_set: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -105,26 +131,22 @@ def prepare_request(next_link=None): skip=skip, tags=tags, expand_api_version_set=expand_api_version_set, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -138,7 +160,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,52 +172,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - api_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,56 +231,61 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - **kwargs: Any - ) -> "_models.ApiContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -260,76 +294,181 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: Union[_models.ApiCreateOrUpdateParameter, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.ApiContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiContract"]] + ) -> Optional[_models.ApiContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiContract]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -337,24 +476,27 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: Union[_models.ApiCreateOrUpdateParameter, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type parameters: ~api_management_client.models.ApiCreateOrUpdateParameter + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -365,55 +507,132 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ApiContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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('ApiContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates the specified API of the API Management service instance. - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -422,52 +641,76 @@ async def update( service_name: str, api_id: str, if_match: str, - parameters: "_models.ApiUpdateContract", + parameters: Union[_models.ApiUpdateContract, IO], **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Updates the specified API of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: API Update Contract parameters. - :type parameters: ~api_management_client.models.ApiUpdateContract + :param parameters: API Update Contract parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] - _json = self._serialize.body(parameters, 'ApiUpdateContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -476,20 +719,19 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -500,30 +742,37 @@ async def delete( ) -> None: """Deletes the specified API of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + :param delete_revisions: Delete all revisions of the Api. Default value is None. :type delete_revisions: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -531,12 +780,18 @@ async def delete( subscription_id=self._config.subscription_id, if_match=if_match, delete_revisions=delete_revisions, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -547,8 +802,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace def list_by_tags( @@ -560,12 +814,12 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_apis: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable["_models.TagResourceContract"]: """Lists a collection of apis associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -575,29 +829,38 @@ def list_by_tags( 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 | |
. + contains, startswith, endswith |
| isCurrent | filter | eq | |
. Default value is + None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_apis: Include not tagged APIs. + :param include_not_tagged_apis: Include not tagged APIs. Default value is None. :type include_not_tagged_apis: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) + :return: An iterator like instance of either TagResourceContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -606,25 +869,22 @@ def prepare_request(next_link=None): top=top, skip=skip, include_not_tagged_apis=include_not_tagged_apis, - template_url=self.list_by_tags.metadata['url'], + api_version=api_version, + template_url=self.list_by_tags.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -638,7 +898,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -648,8 +910,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags'} # type: ignore + list_by_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py index 7468a5351c073..8b451a926c766 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,85 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_api_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiPolicyOperations: - """ApiPolicyOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - 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, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -91,15 +113,14 @@ async def list_by_api( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies'} # type: ignore - + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -107,44 +128,57 @@ async def get_entity_tag( resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -153,15 +187,13 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace_async async def get( @@ -169,35 +201,43 @@ async def get( resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -205,12 +245,18 @@ async def get( policy_id=policy_id, subscription_id=self._config.subscription_id, format=format, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 200]: @@ -220,22 +266,97 @@ async def get( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -243,41 +364,57 @@ async def create_or_update( resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -285,15 +422,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -303,59 +447,65 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -363,12 +513,18 @@ async def delete( policy_id=policy_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +535,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # 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 index 4115220ddd943..37aba616bc215 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_product_operations import build_list_by_apis_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiProductOperations: - """ApiProductOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_product` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,37 +63,48 @@ def list_by_apis( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ProductCollection"]: + ) -> AsyncIterable["_models.ProductContract"]: """Lists all Products, which the API is part of. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductCollection or the result of cls(response) + :return: An iterator like instance of either ProductContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ProductCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -95,25 +113,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_apis.metadata['url'], + api_version=api_version, + template_url=self.list_by_apis.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,7 +142,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -137,8 +154,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_apis.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products'} # type: ignore + list_by_apis.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py index ee7535134d3f3..61ca943ed76b1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_release_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiReleaseOperations: - """ApiReleaseOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiReleaseOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_release` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,40 +71,50 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiReleaseCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiReleaseCollection or the result of - cls(response) + :return: An iterator like instance of either ApiReleaseContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiReleaseCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -98,25 +123,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,7 +152,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,56 +164,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type release_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,60 +229,67 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - release_id: str, - **kwargs: Any - ) -> "_models.ApiReleaseContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type release_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -260,17 +298,94 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -279,40 +394,57 @@ async def create_or_update( service_name: str, api_id: str, release_id: str, - parameters: "_models.ApiReleaseContract", + parameters: Union[_models.ApiReleaseContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Creates a new Release for the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type release_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseContract] - _json = self._serialize.body(parameters, 'ApiReleaseContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -320,15 +452,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -338,22 +477,99 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -363,39 +579,57 @@ async def update( api_id: str, release_id: str, if_match: str, - parameters: "_models.ApiReleaseContract", + parameters: Union[_models.ApiReleaseContract, IO], **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: API Release Update parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :param parameters: API Release Update parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiReleaseContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, @@ -403,15 +637,22 @@ async def update( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -420,54 +661,55 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -475,12 +717,18 @@ async def delete( release_id=release_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -491,5 +739,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # 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 index 4dd25937a47bc..99b2a77e41e58 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_revision_operations import build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiRevisionOperations: - """ApiRevisionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_revision` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,38 +63,48 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiRevisionCollection"]: + ) -> AsyncIterable["_models.ApiRevisionContract"]: """Lists all revisions of an API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiRevisionCollection or the result of - cls(response) + :return: An iterator like instance of either ApiRevisionContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiRevisionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiRevisionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -96,25 +113,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +142,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,8 +154,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py index 6f7c5b8ddc6be..3d01bf9dbec3d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_schema_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_api_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiSchemaOperations: - """ApiSchemaOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -58,37 +72,48 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SchemaCollection"]: + ) -> AsyncIterable["_models.SchemaContract"]: """Get the schema configuration at the API level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SchemaCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SchemaCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SchemaCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -97,25 +122,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +151,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,57 +163,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,61 +228,67 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - schema_id: str, - **kwargs: Any - ) -> "_models.SchemaContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.SchemaContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SchemaContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,17 +297,16 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SchemaContract', pipeline_response) + deserialized = self._deserialize("SchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore async def _create_or_update_initial( self, @@ -279,60 +314,174 @@ async def _create_or_update_initial( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: Union[_models.SchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.SchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SchemaContract"]] + ) -> Optional[_models.SchemaContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SchemaContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SchemaContract]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SchemaContract", is_xml=True) + + 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -341,27 +490,30 @@ async def begin_create_or_update( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: Union[_models.SchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SchemaContract"]: + ) -> AsyncLROPoller[_models.SchemaContract]: """Creates or updates schema configuration for the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + instance. Required. :type schema_id: str - :param parameters: The schema contents to apply. - :type parameters: ~api_management_client.models.SchemaContract + :param parameters: The schema contents to apply. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -372,59 +524,66 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.SchemaContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SchemaContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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('SchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -436,33 +595,41 @@ async def delete( ) -> None: """Deletes the schema configuration at the Api. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + 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. + :param force: If true removes all references to the schema before deleting it. Default value is + None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -471,12 +638,18 @@ async def delete( subscription_id=self._config.subscription_id, if_match=if_match, force=force, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -487,5 +660,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # 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 index 9131ad1cfb641..9c2f3b7da720b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_tag_description_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiTagDescriptionOperations: - """ApiTagDescriptionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiTagDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,41 +70,51 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagDescriptionCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagDescriptionCollection or the result of + :return: An iterator like instance of either TagDescriptionContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagDescriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDescriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -99,25 +123,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +152,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,57 +164,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + API/Tag association. Based on API and Tag names. Required. :type tag_description_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,61 +229,67 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + API/Tag association. Based on API and Tag names. Required. :type tag_description_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagDescriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDescriptionContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -263,17 +298,94 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + deserialized = self._deserialize("TagDescriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -282,41 +394,57 @@ async def create_or_update( service_name: str, api_id: str, tag_description_id: str, - parameters: "_models.TagDescriptionCreateParameters", + parameters: Union[_models.TagDescriptionCreateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagDescriptionContract": + ) -> _models.TagDescriptionContract: """Create/Update tag description in scope of the Api. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + API/Tag association. Based on API and Tag names. Required. :type tag_description_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.TagDescriptionCreateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagDescriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDescriptionContract] - _json = self._serialize.body(parameters, 'TagDescriptionCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagDescriptionCreateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -324,15 +452,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -342,25 +477,24 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagDescriptionContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagDescriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -371,31 +505,38 @@ async def delete( ) -> None: """Delete tag description for the Api. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -403,12 +544,18 @@ async def delete( tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -419,5 +566,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # 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 index 90112d0b71c8a..ae39e0dff57a2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._api_version_set_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiVersionSetOperations: - """ApiVersionSetOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiVersionSetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,35 +70,45 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiVersionSetCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
. + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiVersionSetCollection or the result of + :return: An iterator like instance of either ApiVersionSetContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiVersionSetCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -91,24 +116,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -122,7 +145,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,52 +157,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets"} # type: ignore @distributed_trace_async async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - version_set_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type version_set_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,56 +218,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - version_set_id: str, - **kwargs: Any - ) -> "_models.ApiVersionSetContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type version_set_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -244,17 +283,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -262,53 +370,76 @@ async def create_or_update( resource_group_name: str, service_name: str, version_set_id: str, - parameters: "_models.ApiVersionSetContract", + parameters: Union[_models.ApiVersionSetContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Creates or Updates a Api Version Set. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type version_set_id: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetContract] - _json = self._serialize.body(parameters, 'ApiVersionSetContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiVersionSetContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -318,22 +449,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -342,52 +542,75 @@ async def update( service_name: str, version_set_id: str, if_match: str, - parameters: "_models.ApiVersionSetUpdateParameters", + parameters: Union[_models.ApiVersionSetUpdateParameters, IO], **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Updates the details of the Api VersionSet specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetContract] - _json = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -396,63 +619,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -463,5 +693,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # 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 index bbb4dffb26626..fab63a3a80757 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._authorization_server_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_secrets_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AuthorizationServerOperations: - """AuthorizationServerOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AuthorizationServerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_server` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,38 +71,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.AuthorizationServerCollection"]: + ) -> AsyncIterable["_models.AuthorizationServerContract"]: """Lists a collection of authorization servers defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationServerCollection or the result of + :return: An iterator like instance of either AuthorizationServerContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.AuthorizationServerCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -94,24 +119,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +148,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -135,51 +160,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - authsid: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,55 +218,62 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - authsid: str, - **kwargs: Any - ) -> "_models.AuthorizationServerContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,17 +282,84 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -263,52 +367,75 @@ async def create_or_update( resource_group_name: str, service_name: str, authsid: str, - parameters: "_models.AuthorizationServerContract", + parameters: Union[_models.AuthorizationServerContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Creates new authorization server or updates an existing authorization server. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerContract] - _json = self._serialize.body(parameters, 'AuthorizationServerContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AuthorizationServerContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -318,22 +445,89 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -342,51 +536,75 @@ async def update( service_name: str, authsid: str, if_match: str, - parameters: "_models.AuthorizationServerUpdateContract", + parameters: Union[_models.AuthorizationServerUpdateContract, IO], **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Updates the details of the authorization server specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: OAuth2 Server settings Update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerUpdateContract + :param parameters: OAuth2 Server settings Update parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AuthorizationServerUpdateContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -395,62 +613,69 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - authsid: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,48 +686,56 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async async def list_secrets( - self, - resource_group_name: str, - service_name: str, - authsid: str, - **kwargs: Any - ) -> "_models.AuthorizationServerSecretsContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerSecretsContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerSecretsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerSecretsContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerSecretsContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -511,14 +744,13 @@ async def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AuthorizationServerSecretsContract', pipeline_response) + deserialized = self._deserialize("AuthorizationServerSecretsContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py index 75335b4c780d5..a15b5595836b5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._backend_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_reconnect_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BackendOperations: - """BackendOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BackendOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`backend` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,37 +71,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.BackendCollection"]: + ) -> AsyncIterable["_models.BackendContract"]: """Lists a collection of backends in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackendCollection or the result of cls(response) + :return: An iterator like instance of either BackendContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.BackendCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -93,24 +119,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +148,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,52 +160,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,56 +219,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - **kwargs: Any - ) -> "_models.BackendContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,17 +284,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('BackendContract', pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -264,53 +371,76 @@ async def create_or_update( resource_group_name: str, service_name: str, backend_id: str, - parameters: "_models.BackendContract", + parameters: Union[_models.BackendContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Creates or Updates a backend. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.BackendContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendContract] - _json = self._serialize.body(parameters, 'BackendContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackendContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -320,22 +450,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('BackendContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('BackendContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -344,52 +543,75 @@ async def update( service_name: str, backend_id: str, if_match: str, - parameters: "_models.BackendUpdateParameters", + parameters: Union[_models.BackendUpdateParameters, IO], **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Updates an existing backend. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.BackendUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'BackendUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,63 +620,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('BackendContract', pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -465,61 +694,148 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore + + @overload + async def reconnect( # pylint: disable=inconsistent-return-statements + 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 APIM proxy 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def reconnect( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the APIM proxy 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def reconnect( + async def reconnect( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, backend_id: str, - parameters: Optional["_models.BackendReconnectContract"] = None, + parameters: Optional[Union[_models.BackendReconnectContract, IO]] = None, **kwargs: Any ) -> None: """Notifies the APIM proxy 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str - :param parameters: Reconnect request parameters. - :type parameters: ~api_management_client.models.BackendReconnectContract + :param parameters: Reconnect request parameters. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if parameters is not None: - _json = self._serialize.body(parameters, 'BackendReconnectContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "BackendReconnectContract", is_xml=True) + 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, - template_url=self.reconnect.metadata['url'], + content=_content, + template_url=self.reconnect.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: @@ -530,5 +846,4 @@ async def reconnect( if cls: return cls(pipeline_response, None, {}) - reconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect'} # type: ignore - + reconnect.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect"} # 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 index 4d89b755ee3bc..f01848a9359cc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._cache_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CacheOperations: - """CacheOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CacheOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`cache` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -54,53 +69,61 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.CacheCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CacheCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.CacheCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -114,7 +137,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -124,52 +149,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + or valid Azure region identifier). Required. :type cache_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -178,56 +208,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - **kwargs: Any - ) -> "_models.CacheContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + or valid Azure region identifier). Required. :type cache_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CacheContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -236,17 +273,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CacheContract', pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # 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. + + :param resource_group_name: The name of the resource group. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. + + :param resource_group_name: The name of the resource group. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -254,53 +360,76 @@ async def create_or_update( resource_group_name: str, service_name: str, cache_id: str, - parameters: "_models.CacheContract", + parameters: Union[_models.CacheContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + or valid Azure region identifier). Required. :type cache_id: str - :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CacheContract + :param parameters: Create or Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CacheContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheContract] - _json = self._serialize.body(parameters, 'CacheContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CacheContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -310,22 +439,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CacheContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CacheContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CacheContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CacheContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -334,52 +532,75 @@ async def update( service_name: str, cache_id: str, if_match: str, - parameters: "_models.CacheUpdateParameters", + parameters: Union[_models.CacheUpdateParameters, IO], **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Updates the details of the cache specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.CacheUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CacheContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheContract] - _json = self._serialize.body(parameters, 'CacheUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -388,63 +609,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CacheContract', pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -455,5 +683,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # 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 index ab26b2c727379..35096b00dd3f4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificate_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_refresh_secret_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificateOperations: - """CertificateOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`certificate` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,42 +71,50 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.CertificateCollection"]: + ) -> AsyncIterable["_models.CertificateContract"]: """Lists a collection of all certificates in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :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. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateCollection or the result of - cls(response) + :return: An iterator like instance of either CertificateContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.CertificateCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -100,25 +123,22 @@ def prepare_request(next_link=None): top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +152,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,52 +164,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates"} # type: ignore @distributed_trace_async async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,56 +225,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - **kwargs: Any - ) -> "_models.CertificateContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -254,17 +290,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CertificateContract', pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # 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. + + :param resource_group_name: The name of the resource group. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. + :param resource_group_name: The name of the resource group. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -272,53 +377,76 @@ async def create_or_update( resource_group_name: str, service_name: str, certificate_id: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """Creates or updates the certificate being used for authentication with the backend. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str - :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CertificateCreateOrUpdateParameters + :param parameters: Create or Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -328,68 +456,75 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CertificateContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CertificateContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -400,49 +535,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace_async async def refresh_secret( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - **kwargs: Any - ) -> "_models.CertificateContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateContract] - 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, - template_url=self.refresh_secret.metadata['url'], + api_version=api_version, + template_url=self.refresh_secret.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -451,14 +594,13 @@ async def refresh_secret( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CertificateContract', pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret'} # type: ignore - + refresh_secret.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py index 4a2398e809dae..0f4655f49680d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._content_item_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContentItemOperations: - """ContentItemOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContentItemOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`content_item` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ContentItemCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContentItemCollection or the result of - cls(response) + :return: An iterator like instance of either ContentItemContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ContentItemCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentItemContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentItemCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +129,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,56 +141,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :param content_item_id: Content item identifier. Required. :type content_item_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,59 +205,65 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :param content_item_id: Content item identifier. Required. :type content_item_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentItemContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentItemContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,17 +272,16 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ContentItemContract', pipeline_response) + deserialized = self._deserialize("ContentItemContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace_async async def create_or_update( @@ -261,32 +292,39 @@ async def create_or_update( content_item_id: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ContentItemContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :param content_item_id: Content item identifier. Required. :type content_item_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentItemContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentItemContract] - request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, @@ -294,12 +332,18 @@ async def create_or_update( content_item_id=content_item_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,25 +353,24 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentItemContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentItemContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentItemContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentItemContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -338,29 +381,36 @@ async def delete( ) -> None: """Removes the specified developer portal's content item. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -368,12 +418,18 @@ async def delete( content_item_id=content_item_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -384,5 +440,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # 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 index 1585a8e5ad8b1..b0e69d8a747a0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._content_type_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +from ...operations._content_type_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_service_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContentTypeOperations: - """ContentTypeOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContentTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`content_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ContentTypeCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContentTypeCollection or the result of - cls(response) + :return: An iterator like instance of either ContentTypeContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ContentTypeCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentTypeContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentTypeCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -107,7 +126,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,52 +138,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - **kwargs: Any - ) -> "_models.ContentTypeContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentTypeContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentTypeContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,17 +199,16 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ContentTypeContract', pipeline_response) + deserialized = self._deserialize("ContentTypeContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore @distributed_trace_async async def create_or_update( @@ -191,44 +218,57 @@ async def create_or_update( content_type_id: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ContentTypeContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentTypeContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,69 +278,76 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentTypeContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentTypeContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentTypeContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentTypeContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -311,5 +358,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # 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 index 46526b90ade20..3b2ccb1dc1979 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,100 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._delegation_settings_operations import build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_list_secrets_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DelegationSettingsOperations: - """DelegationSettingsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DelegationSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`delegation_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,51 +108,57 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalDelegationSettings": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalDelegationSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalDelegationSettings] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,66 +167,150 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore + @overload + async def update( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + if_match: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def update( + async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalDelegationSettings", + parameters: Union[_models.PortalDelegationSettings, IO], **kwargs: Any ) -> None: """Update Delegation settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update Delegation settings. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :param parameters: Update Delegation settings. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalDelegationSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalDelegationSettings", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -210,57 +321,141 @@ async def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PortalDelegationSettings", + parameters: Union[_models.PortalDelegationSettings, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalDelegationSettings": + ) -> _models.PortalDelegationSettings: """Create or Update Delegation settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalDelegationSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalDelegationSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalDelegationSettings] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalDelegationSettings", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -268,51 +463,60 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace_async async def list_secrets( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalSettingValidationKeyContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSettingValidationKeyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingValidationKeyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSettingValidationKeyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingValidationKeyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSettingValidationKeyContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -320,12 +524,11 @@ async def list_secrets( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSettingValidationKeyContract', pipeline_response) + deserialized = self._deserialize("PortalSettingValidationKeyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py index f8fc7ea2823a3..9ca53fbb640a4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._deleted_services_operations import build_get_by_name_request, build_list_by_subscription_request, build_purge_request_initial -T = TypeVar('T') +from ...operations._deleted_services_operations import ( + build_get_by_name_request, + build_list_by_subscription_request, + build_purge_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeletedServicesOperations: - """DeletedServicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`deleted_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.DeletedServicesCollection"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DeletedServiceContract"]: """Lists all soft-deleted services available for undelete for the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedServicesCollection or the result of + :return: An iterator like instance of either DeletedServiceContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.DeletedServicesCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServicesCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedServicesCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,7 +119,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,47 +131,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices"} # type: ignore @distributed_trace_async - async def get_by_name( - self, - service_name: str, - location: str, - **kwargs: Any - ) -> "_models.DeletedServiceContract": + 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. + :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. + :param location: The location of the deleted API Management service. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedServiceContract, or the result of cls(response) - :rtype: ~api_management_client.models.DeletedServiceContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DeletedServiceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedServiceContract] - request = build_get_by_name_request( service_name=service_name, - subscription_id=self._config.subscription_id, location=location, - template_url=self.get_by_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -156,69 +185,73 @@ async def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore - + get_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore async def _purge_initial( - self, - service_name: str, - location: str, - **kwargs: Any - ) -> Optional["_models.DeletedServiceContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeletedServiceContract"]] + self, service_name: str, location: str, **kwargs: Any + ) -> Optional[_models.DeletedServiceContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeletedServiceContract]] - - request = build_purge_request_initial( + request = build_purge_request( service_name=service_name, - subscription_id=self._config.subscription_id, location=location, - template_url=self._purge_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._purge_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: - deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _purge_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore - + _purge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_purge( - self, - service_name: str, - location: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.DeletedServiceContract"]: + async def begin_purge(self, service_name: str, location: str, **kwargs: Any) -> AsyncLROPoller[None]: """Purges Api Management Service (deletes it with no option to undelete). - :param service_name: The name of the API Management service. + :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. + :param location: The location of the deleted API Management service. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -231,44 +264,50 @@ async def begin_purge( :return: An instance of AsyncLROPoller that returns either DeletedServiceContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.DeletedServiceContract] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._purge_initial( + raw_result = await self._purge_initial( # type: ignore service_name=service_name, location=location, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_purge.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + begin_purge.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # 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 index 9e620c5eb7157..79161d30676da 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._diagnostic_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DiagnosticOperations: - """DiagnosticOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`diagnostic` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,36 +70,45 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DiagnosticCollection"]: + ) -> AsyncIterable["_models.DiagnosticContract"]: """Lists all diagnostics of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticCollection or the result of - cls(response) + :return: An iterator like instance of either DiagnosticContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.DiagnosticCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -92,24 +116,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,7 +145,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -133,52 +157,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics"} # type: ignore @distributed_trace_async async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - diagnostic_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,56 +218,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - diagnostic_id: str, - **kwargs: Any - ) -> "_models.DiagnosticContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,17 +283,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -263,53 +370,76 @@ async def create_or_update( resource_group_name: str, service_name: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - _json = self._serialize.body(parameters, 'DiagnosticContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -319,22 +449,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -343,52 +542,75 @@ async def update( service_name: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Updates the details of the Diagnostic specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Diagnostic Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - _json = self._serialize.body(parameters, 'DiagnosticContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -397,63 +619,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - diagnostic_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +693,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # 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 index 88ef6c0e8bd27..a47936d0b2a73 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._email_template_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class EmailTemplateOperations: - """EmailTemplateOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EmailTemplateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`email_template` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,36 +70,46 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EmailTemplateCollection"]: + ) -> AsyncIterable["_models.EmailTemplateContract"]: """Gets all email templates. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EmailTemplateCollection or the result of + :return: An iterator like instance of either EmailTemplateContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.EmailTemplateCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -92,24 +117,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,7 +146,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -133,51 +158,69 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates"} # type: ignore @distributed_trace_async async def get_entity_tag( self, resource_group_name: str, service_name: str, - template_name: Union[str, "_models.TemplateName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,55 +229,73 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, - template_name: Union[str, "_models.TemplateName"], + template_name: Union[str, _models.TemplateName], **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Gets the details of the email template specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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 callable cls: A custom type or function that will be passed the direct response - :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: EmailTemplateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -243,70 +304,182 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.EmailTemplateUpdateParameters", + template_name: Union[str, _models.TemplateName], + parameters: Union[_models.EmailTemplateUpdateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates an Email Template. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName - :param parameters: Email Template update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: EmailTemplateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateContract] - _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -315,71 +488,182 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + template_name: Union[str, _models.TemplateName], if_match: str, - parameters: "_models.EmailTemplateUpdateParameters", + parameters: Union[_models.EmailTemplateUpdateParameters, IO], **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates API Management email template. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: EmailTemplateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateContract] - _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -388,62 +672,81 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - template_name: Union[str, "_models.TemplateName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -454,5 +757,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # 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 index 8c2df8e97d6f0..72c5515d804ba 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_api_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_list_by_service_request -T = TypeVar('T') +from ...operations._gateway_api_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_list_by_service_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayApiOperations: - """GatewayApiOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway_api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,37 +69,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollection"]: + ) -> AsyncIterable["_models.ApiContract"]: """Lists a collection of the APIs associated with a gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -95,25 +118,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,7 +147,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -137,56 +159,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis"} # type: ignore @distributed_trace_async async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,15 +224,83 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore + @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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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] = 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -212,39 +309,56 @@ async def create_or_update( service_name: str, gateway_id: str, api_id: str, - parameters: Optional["_models.AssociationContract"] = None, + parameters: Optional[Union[_models.AssociationContract, IO]] = None, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Adds an API to the specified Gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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: - :type parameters: ~api_management_client.models.AssociationContract + :param parameters: Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if parameters is not None: - _json = self._serialize.body(parameters, 'AssociationContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "AssociationContract", is_xml=True) + else: + _json = None request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,14 +366,21 @@ async def create_or_update( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -268,63 +389,71 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -335,5 +464,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # 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 index ca28a4ce94ea3..60b0c7fcb135e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_certificate_authority_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayCertificateAuthorityOperations: - """GatewayCertificateAuthorityOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayCertificateAuthorityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,39 +70,48 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GatewayCertificateAuthorityCollection"]: + ) -> AsyncIterable["_models.GatewayCertificateAuthorityContract"]: """Lists the collection of Certificate Authorities for the specified Gateway entity. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | eq, ne | |
. + filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCertificateAuthorityCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCertificateAuthorityContract or the result + of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GatewayCertificateAuthorityCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCertificateAuthorityCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -97,25 +120,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +149,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,57 +161,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,61 +226,67 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayCertificateAuthorityContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCertificateAuthorityContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,17 +295,94 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -280,41 +391,57 @@ async def create_or_update( service_name: str, gateway_id: str, certificate_id: str, - parameters: "_models.GatewayCertificateAuthorityContract", + parameters: Union[_models.GatewayCertificateAuthorityContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + ) -> _models.GatewayCertificateAuthorityContract: """Assign Certificate entity to Gateway entity as Certificate Authority. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Management service instance. Required. :type certificate_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayCertificateAuthorityContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayCertificateAuthorityContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCertificateAuthorityContract] - _json = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayCertificateAuthorityContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -322,15 +449,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -340,25 +474,24 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -369,31 +502,38 @@ async def delete( ) -> None: """Remove relationship between Certificate Authority and Gateway entity. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -401,12 +541,18 @@ async def delete( certificate_id=certificate_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -417,5 +563,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # 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 index 377299dba9ce3..7ae5b1f0e8054 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_hostname_configuration_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayHostnameConfigurationOperations: - """GatewayHostnameConfigurationOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayHostnameConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,40 +70,50 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GatewayHostnameConfigurationCollection"]: + ) -> AsyncIterable["_models.GatewayHostnameConfigurationContract"]: """Lists the collection of hostname configurations for the specified gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayHostnameConfigurationContract or the result + of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GatewayHostnameConfigurationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayHostnameConfigurationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -98,25 +122,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,7 +151,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,58 +163,64 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Gateway entity. Required. :type hc_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,61 +229,67 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Gateway entity. Required. :type hc_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayHostnameConfigurationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayHostnameConfigurationContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -263,17 +298,94 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -282,41 +394,57 @@ async def create_or_update( service_name: str, gateway_id: str, hc_id: str, - parameters: "_models.GatewayHostnameConfigurationContract", + parameters: Union[_models.GatewayHostnameConfigurationContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + ) -> _models.GatewayHostnameConfigurationContract: """Creates of updates hostname configuration for a Gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Gateway entity. Required. :type hc_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayHostnameConfigurationContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayHostnameConfigurationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayHostnameConfigurationContract] - _json = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayHostnameConfigurationContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -324,15 +452,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -342,60 +477,60 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -403,12 +538,18 @@ async def delete( hc_id=hc_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -419,5 +560,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # 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 index 9532624637ec8..0809d4740bb18 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._gateway_operations import build_create_or_update_request, build_delete_request, build_generate_token_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_keys_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +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_list_by_service_request, + build_list_keys_request, + build_regenerate_key_request, + build_update_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GatewayOperations: - """GatewayOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,38 +73,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GatewayCollection"]: + ) -> AsyncIterable["_models.GatewayContract"]: """Lists a collection of gateways registered with service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCollection or the result of cls(response) + :return: An iterator like instance of either GatewayContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GatewayCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -94,24 +121,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +150,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -135,52 +162,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,56 +221,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - **kwargs: Any - ) -> "_models.GatewayContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -247,17 +286,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayContract', pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -265,53 +373,76 @@ async def create_or_update( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayContract", + parameters: Union[_models.GatewayContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Creates or updates a Gateway to be used in Api Management instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayContract] - _json = self._serialize.body(parameters, 'GatewayContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -321,22 +452,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -345,52 +545,75 @@ async def update( service_name: str, gateway_id: str, if_match: str, - parameters: "_models.GatewayContract", + parameters: Union[_models.GatewayContract, IO], **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Updates the details of the gateway specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GatewayContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayContract", is_xml=True) request = build_update_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, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,63 +622,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayContract', pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -466,49 +696,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - **kwargs: Any - ) -> "_models.GatewayKeysContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayKeysContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayKeysContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayKeysContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayKeysContract] - 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, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -517,66 +755,150 @@ async def list_keys( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayKeysContract', pipeline_response) + deserialized = self._deserialize("GatewayKeysContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys"} # type: ignore + + @overload + async def regenerate_key( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def regenerate_key( + async def regenerate_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayKeyRegenerationRequestContract", + parameters: Union[_models.GatewayKeyRegenerationRequestContract, IO], **kwargs: Any ) -> None: """Regenerates specified gateway key invalidating any tokens created with it. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayKeyRegenerationRequestContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -587,8 +909,69 @@ async def regenerate_key( if cls: return cls(pipeline_response, None, {}) - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey'} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -596,48 +979,71 @@ async def generate_token( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayTokenRequestContract", + parameters: Union[_models.GatewayTokenRequestContract, IO], **kwargs: Any - ) -> "_models.GatewayTokenContract": + ) -> _models.GatewayTokenContract: """Gets the Shared Access Authorization Token for the gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayTokenRequestContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayTokenContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayTokenContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayTokenContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayTokenContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayTokenContract] - _json = self._serialize.body(parameters, 'GatewayTokenRequestContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.generate_token.metadata['url'], + content=_content, + template_url=self.generate_token.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -645,12 +1051,11 @@ async def generate_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayTokenContract', pipeline_response) + deserialized = self._deserialize("GatewayTokenContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken'} # type: ignore - + generate_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py index 936b21136c7ae..f85a9c4b2361c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._global_schema_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GlobalSchemaOperations: - """GlobalSchemaOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GlobalSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`global_schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,36 +71,46 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GlobalSchemaCollection"]: + ) -> AsyncIterable["_models.GlobalSchemaContract"]: """Lists a collection of schemas registered with service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GlobalSchemaCollection or the result of + :return: An iterator like instance of either GlobalSchemaContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GlobalSchemaCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GlobalSchemaCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -94,24 +118,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +147,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -135,52 +159,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - schema_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,56 +218,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - schema_id: str, - **kwargs: Any - ) -> "_models.GlobalSchemaContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GlobalSchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.GlobalSchemaContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GlobalSchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GlobalSchemaContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -247,76 +283,183 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: Union[_models.GlobalSchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.GlobalSchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GlobalSchemaContract"]] + ) -> Optional[_models.GlobalSchemaContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GlobalSchemaContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GlobalSchemaContract]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GlobalSchemaContract", is_xml=True) + + 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -324,24 +467,27 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: Union[_models.GlobalSchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.GlobalSchemaContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type schema_id: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.GlobalSchemaContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -352,101 +498,117 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GlobalSchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.GlobalSchemaContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GlobalSchemaContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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('GlobalSchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - schema_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -457,5 +619,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # 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 index 6e5205129cf04..896f5168126c6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._group_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GroupOperations: - """GroupOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,37 +70,46 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GroupCollection"]: + ) -> AsyncIterable["_models.GroupContract"]: """Lists a collection of groups defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + endswith |
| externalId | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GroupCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -93,24 +117,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +146,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,52 +158,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - group_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,56 +217,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,17 +282,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -264,53 +369,76 @@ async def create_or_update( resource_group_name: str, service_name: str, group_id: str, - parameters: "_models.GroupCreateParameters", + parameters: Union[_models.GroupCreateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Creates or Updates a group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.GroupCreateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] - _json = self._serialize.body(parameters, 'GroupCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -320,22 +448,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GroupContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GroupContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -344,52 +541,75 @@ async def update( service_name: str, group_id: str, if_match: str, - parameters: "_models.GroupUpdateParameters", + parameters: Union[_models.GroupUpdateParameters, IO], **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Updates the details of the group specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.GroupUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] - _json = self._serialize.body(parameters, 'GroupUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,63 +618,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - group_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -465,5 +692,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # 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 index b56c432125530..69df569336548 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._group_user_operations import build_check_entity_exists_request, build_create_request, build_delete_request, build_list_request -T = TypeVar('T') +from ...operations._group_user_operations import ( + build_check_entity_exists_request, + build_create_request, + build_delete_request, + build_list_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GroupUserOperations: - """GroupUserOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GroupUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`group_user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,15 +69,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.UserCollection"]: + ) -> AsyncIterable["_models.UserContract"]: """Lists a collection of user entities associated with the group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -73,25 +86,34 @@ def list( 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 |
. + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.UserCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -100,25 +122,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +151,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,56 +163,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users"} # type: ignore @distributed_trace_async async def check_entity_exists( - self, - resource_group_name: str, - service_name: str, - group_id: str, - user_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -203,53 +231,61 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace_async async def create( - self, - resource_group_name: str, - service_name: str, - group_id: str, - user_id: str, - **kwargs: Any - ) -> "_models.UserContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] - 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, - template_url=self.create.metadata['url'], + api_version=api_version, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -258,63 +294,71 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - group_id: str, - user_id: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -325,5 +369,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # 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 index de7c1908612da..f3957ca89a3fc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._identity_provider_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_secrets_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IdentityProviderOperations: - """IdentityProviderOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IdentityProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`identity_provider` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.IdentityProviderList"]: + 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. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IdentityProviderList or the result of + :return: An iterator like instance of either IdentityProviderContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IdentityProviderList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -106,7 +129,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -116,51 +141,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders"} # 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"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,56 +206,68 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, - identity_provider_name: Union[str, "_models.IdentityProviderType"], + identity_provider_name: Union[str, _models.IdentityProviderType], **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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 callable cls: A custom type or function that will be passed the direct response - :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IdentityProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -227,70 +276,163 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.IdentityProviderCreateContract", + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: Union[_models.IdentityProviderCreateContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Creates or Updates the IdentityProvider configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IdentityProviderCreateContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IdentityProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'IdentityProviderCreateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IdentityProviderCreateContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -300,75 +442,168 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + identity_provider_name: Union[str, _models.IdentityProviderType], if_match: str, - parameters: "_models.IdentityProviderUpdateParameters", + parameters: Union[_models.IdentityProviderUpdateParameters, IO], **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Updates an existing IdentityProvider configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IdentityProviderUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IdentityProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -377,62 +612,75 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - identity_provider_name: Union[str, "_models.IdentityProviderType"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -443,48 +691,61 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async async def list_secrets( self, resource_group_name: str, service_name: str, - identity_provider_name: Union[str, "_models.IdentityProviderType"], + identity_provider_name: Union[str, _models.IdentityProviderType], **kwargs: Any - ) -> "_models.ClientSecretContract": + ) -> _models.ClientSecretContract: """Gets the client secret details of the Identity Provider. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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 callable cls: A custom type or function that will be passed the direct response - :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ClientSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientSecretContract] - 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, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -493,14 +754,13 @@ async def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ClientSecretContract', pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py index c98e6d6204360..b1dec7b6d2909 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._issue_operations import build_get_request, build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IssueOperations: - """IssueOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`issue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,12 +63,12 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueCollection"]: + ) -> AsyncIterable["_models.IssueContract"]: """Lists a collection of issues in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -69,25 +77,34 @@ def list_by_service( 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 | |
. + endswith |
| state | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -95,24 +112,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +141,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,52 +153,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - issue_id: str, - **kwargs: Any - ) -> "_models.IssueContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, issue_id=issue_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,14 +214,13 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueContract', pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py index 3de82e8a7bc01..92d6bbeb1cabf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._logger_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class LoggerOperations: - """LoggerOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LoggerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`logger` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,37 +70,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.LoggerCollection"]: + ) -> AsyncIterable["_models.LoggerContract"]: """Lists a collection of loggers in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LoggerCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.LoggerCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -93,24 +118,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +147,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,51 +159,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - logger_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,55 +218,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - logger_id: str, - **kwargs: Any - ) -> "_models.LoggerContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -244,17 +283,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LoggerContract', pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -262,52 +370,76 @@ async def create_or_update( resource_group_name: str, service_name: str, logger_id: str, - parameters: "_models.LoggerContract", + parameters: Union[_models.LoggerContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Creates or Updates a logger. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.LoggerContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerContract] - _json = self._serialize.body(parameters, 'LoggerContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LoggerContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -317,22 +449,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('LoggerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('LoggerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -341,51 +542,75 @@ async def update( service_name: str, logger_id: str, if_match: str, - parameters: "_models.LoggerUpdateContract", + parameters: Union[_models.LoggerUpdateContract, IO], **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Updates an existing logger. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.LoggerUpdateContract + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerContract] - _json = self._serialize.body(parameters, 'LoggerUpdateContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -394,62 +619,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LoggerContract', pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - logger_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -460,5 +693,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # 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 index 32e37b7e7354d..49bac9c803655 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._named_value_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_value_request, build_refresh_secret_request_initial, build_update_request_initial -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NamedValueOperations: - """NamedValueOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NamedValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`named_value` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -58,41 +75,49 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.NamedValueCollection"]: + ) -> AsyncIterable["_models.NamedValueContract"]: """Lists a collection of named values defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :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. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamedValueCollection or the result of - cls(response) + :return: An iterator like instance of either NamedValueContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.NamedValueCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -101,25 +126,22 @@ def prepare_request(next_link=None): top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,7 +155,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,51 +167,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues"} # type: ignore @distributed_trace_async async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,55 +227,62 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - **kwargs: Any - ) -> "_models.NamedValueContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamedValueContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NamedValueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,76 +291,179 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('NamedValueContract', pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: Union[_models.NamedValueCreateContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'NamedValueCreateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamedValueContract]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueCreateContract", is_xml=True) + + 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -330,23 +471,26 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: Union[_models.NamedValueCreateContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.NamedValueContract"]: + ) -> AsyncLROPoller[_models.NamedValueContract]: """Creates or updates named value. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.NamedValueCreateContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -357,55 +501,62 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.NamedValueContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore async def _update_initial( self, @@ -413,53 +564,157 @@ async def _update_initial( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: Union[_models.NamedValueUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamedValueContract]] - _json = self._serialize.body(parameters, 'NamedValueUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueUpdateParameters") - request = build_update_request_initial( + 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -468,22 +723,25 @@ async def begin_update( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: Union[_models.NamedValueUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.NamedValueContract"]: + ) -> AsyncLROPoller[_models.NamedValueContract]: """Updates the specific named value. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.NamedValueUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -494,100 +752,115 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.NamedValueContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -598,48 +871,56 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamedValueSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueSecretContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NamedValueSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueSecretContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueSecretContract] - 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, - template_url=self.list_value.metadata['url'], + api_version=api_version, + template_url=self.list_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -648,79 +929,83 @@ async def list_value( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('NamedValueSecretContract', pipeline_response) + deserialized = self._deserialize("NamedValueSecretContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_value.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue'} # type: ignore - + list_value.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue"} # type: ignore async def _refresh_secret_initial( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + self, resource_group_name: str, service_name: str, named_value_id: str, **kwargs: Any + ) -> Optional[_models.NamedValueContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamedValueContract]] - - request = build_refresh_secret_request_initial( + 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, - template_url=self._refresh_secret_initial.metadata['url'], + api_version=api_version, + template_url=self._refresh_secret_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _refresh_secret_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore - + _refresh_secret_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # 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"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -732,48 +1017,55 @@ async def begin_refresh_secret( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.NamedValueContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._refresh_secret_initial( + raw_result = await self._refresh_secret_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore + begin_refresh_secret.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # 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 index 37ccbb58477f8..cab2a74990b43 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._network_status_operations import build_list_by_location_request, build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NetworkStatusOperations: - """NetworkStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NetworkStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`network_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of NetworkStatusContractByLocation, or the result of cls(response) - :rtype: list[~api_management_client.models.NetworkStatusContractByLocation] - :raises: ~azure.core.exceptions.HttpResponseError + :return: list of NetworkStatusContractByLocation or the result of cls(response) + :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.NetworkStatusContractByLocation"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.NetworkStatusContractByLocation]] - request = build_list_by_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - template_url=self.list_by_service.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,58 +105,66 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[NetworkStatusContractByLocation]', pipeline_response) + deserialized = self._deserialize("[NetworkStatusContractByLocation]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + the Azure Regions like West US, East US, South Central US. Required. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkStatusContract, or the result of cls(response) - :rtype: ~api_management_client.models.NetworkStatusContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NetworkStatusContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkStatusContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkStatusContract] - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, location_name=location_name, - template_url=self.list_by_location.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,12 +172,11 @@ async def list_by_location( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkStatusContract', pipeline_response) + deserialized = self._deserialize("NetworkStatusContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus'} # type: ignore - + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py index 75eea4d6b3d6f..0395e568c685c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._notification_operations import build_create_or_update_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +from ...operations._notification_operations import ( + build_create_or_update_request, + build_get_request, + build_list_by_service_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NotificationOperations: - """NotificationOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NotificationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`notification` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -54,55 +66,63 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.NotificationCollection"]: + ) -> AsyncIterable["_models.NotificationContract"]: """Lists a collection of properties defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotificationCollection or the result of + :return: An iterator like instance of either NotificationContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.NotificationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -116,7 +136,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -126,51 +148,65 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications"} # type: ignore @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Gets the details of the Notification specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 callable cls: A custom type or function that will be passed the direct response - :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -178,60 +214,75 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotificationContract', pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore @distributed_trace_async async def create_or_update( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Create or Update API Management publisher notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,12 +290,11 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotificationContract', pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py index f0cf5318d9506..40983ca014cd7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._notification_recipient_email_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_notification_request -T = TypeVar('T') +from ...operations._notification_recipient_email_operations import ( + build_check_entity_exists_request, + build_create_or_update_request, + build_delete_request, + build_list_by_notification_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NotificationRecipientEmailOperations: - """NotificationRecipientEmailOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NotificationRecipientEmailOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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"], + notification_name: Union[str, _models.NotificationName], **kwargs: Any - ) -> "_models.RecipientEmailCollection": + ) -> _models.RecipientEmailCollection: """Gets the list of the Notification Recipient Emails subscribed to a notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 callable cls: A custom type or function that will be passed the direct response - :return: RecipientEmailCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientEmailCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientEmailCollection] - 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, - template_url=self.list_by_notification.metadata['url'], + api_version=api_version, + template_url=self.list_by_notification.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,59 +118,74 @@ async def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RecipientEmailCollection', pipeline_response) + deserialized = self._deserialize("RecipientEmailCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails'} # type: ignore - + list_by_notification.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails"} # type: ignore @distributed_trace_async async def check_entity_exists( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName - :param email: Email identifier. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -154,52 +197,67 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace_async async def create_or_update( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], email: str, **kwargs: Any - ) -> "_models.RecipientEmailContract": + ) -> _models.RecipientEmailContract: """Adds the Email address to the list of Recipients for the Notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName - :param email: Email identifier. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecipientEmailContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientEmailContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientEmailContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -208,62 +266,77 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('RecipientEmailContract', pipeline_response) + deserialized = self._deserialize("RecipientEmailContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('RecipientEmailContract', pipeline_response) + deserialized = self._deserialize("RecipientEmailContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName - :param email: Email identifier. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,5 +347,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # 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 index f62941b881f82..55742440680d2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._notification_recipient_user_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_notification_request -T = TypeVar('T') +from ...operations._notification_recipient_user_operations import ( + build_check_entity_exists_request, + build_create_or_update_request, + build_delete_request, + build_list_by_notification_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NotificationRecipientUserOperations: - """NotificationRecipientUserOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NotificationRecipientUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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"], + notification_name: Union[str, _models.NotificationName], **kwargs: Any - ) -> "_models.RecipientUserCollection": + ) -> _models.RecipientUserCollection: """Gets the list of the Notification Recipient User subscribed to the notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 callable cls: A custom type or function that will be passed the direct response - :return: RecipientUserCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientUserCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientUserCollection] - 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, - template_url=self.list_by_notification.metadata['url'], + api_version=api_version, + template_url=self.list_by_notification.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,59 +118,75 @@ async def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RecipientUserCollection', pipeline_response) + deserialized = self._deserialize("RecipientUserCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers'} # type: ignore - + list_by_notification.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers"} # type: ignore @distributed_trace_async async def check_entity_exists( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -154,52 +198,68 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace_async async def create_or_update( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], user_id: str, **kwargs: Any - ) -> "_models.RecipientUserContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecipientUserContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientUserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientUserContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -208,62 +268,78 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('RecipientUserContract', pipeline_response) + deserialized = self._deserialize("RecipientUserContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('RecipientUserContract', pipeline_response) + deserialized = self._deserialize("RecipientUserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,5 +350,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # 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 index 9358f344731e6..4b597d5fbb9b5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._open_id_connect_provider_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_secrets_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OpenIdConnectProviderOperations: - """OpenIdConnectProviderOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OpenIdConnectProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,38 +71,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.OpenIdConnectProviderCollection"]: + ) -> AsyncIterable["_models.OpenidConnectProviderContract"]: """Lists of all the OpenId Connect Providers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of + :return: An iterator like instance of either OpenidConnectProviderContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.OpenIdConnectProviderCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenIdConnectProviderCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenIdConnectProviderCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -94,24 +119,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +148,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -135,51 +160,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - opid: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,55 +218,62 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - opid: str, - **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OpenidConnectProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenidConnectProviderContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,17 +282,84 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -263,52 +367,75 @@ async def create_or_update( resource_group_name: str, service_name: str, opid: str, - parameters: "_models.OpenidConnectProviderContract", + parameters: Union[_models.OpenidConnectProviderContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Creates or updates the OpenID Connect Provider. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OpenidConnectProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenidConnectProviderContract] - _json = self._serialize.body(parameters, 'OpenidConnectProviderContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenidConnectProviderContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -318,22 +445,89 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -342,51 +536,74 @@ async def update( service_name: str, opid: str, if_match: str, - parameters: "_models.OpenidConnectProviderUpdateContract", + parameters: Union[_models.OpenidConnectProviderUpdateContract, IO], **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Updates the specific OpenID Connect Provider. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderUpdateContract + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OpenidConnectProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenidConnectProviderContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -395,62 +612,69 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - opid: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,48 +685,56 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async async def list_secrets( - self, - resource_group_name: str, - service_name: str, - opid: str, - **kwargs: Any - ) -> "_models.ClientSecretContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ClientSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientSecretContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -511,14 +743,13 @@ async def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ClientSecretContract', pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py index b37cd029b9393..2db2b9e5bc11a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operation_operations import build_list_by_tags_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationOperations: - """OperationOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,15 +64,15 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_operations: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable["_models.TagResourceContract"]: """Lists a collection of operations associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 | @@ -75,29 +82,37 @@ def list_by_tags( |
| 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 |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_operations: Include not tagged Operations. + :param include_not_tagged_operations: Include not tagged Operations. Default value is None. :type include_not_tagged_operations: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) + :return: An iterator like instance of either TagResourceContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -107,26 +122,22 @@ def prepare_request(next_link=None): top=top, skip=skip, include_not_tagged_operations=include_not_tagged_operations, - template_url=self.list_by_tags.metadata['url'], + api_version=api_version, + template_url=self.list_by_tags.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -140,7 +151,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -150,8 +163,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags'} # type: ignore + list_by_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py index 38b1801913504..44a08745c7587 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._outbound_network_dependencies_endpoints_operations import build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OutboundNetworkDependenciesEndpointsOperations: - """OutboundNetworkDependenciesEndpointsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OutboundNetworkDependenciesEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OutboundEnvironmentEndpointList, or the result of cls(response) - :rtype: ~api_management_client.models.OutboundEnvironmentEndpointList - :raises: ~azure.core.exceptions.HttpResponseError + :return: OutboundEnvironmentEndpointList or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEnvironmentEndpointList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OutboundEnvironmentEndpointList] - request = build_list_by_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - template_url=self.list_by_service.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -86,12 +103,11 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OutboundEnvironmentEndpointList', pipeline_response) + deserialized = self._deserialize("OutboundEnvironmentEndpointList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints"} # 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 new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""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 + + +def patch_sdk(): + """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/operations/_policy_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py index 39b0565a0a18d..f961de2aa2d9a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._policy_description_operations import build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyDescriptionOperations: - """PolicyDescriptionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy_description` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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, + scope: Optional[Union[str, _models.PolicyScopeContract]] = None, **kwargs: Any - ) -> "_models.PolicyDescriptionCollection": + ) -> _models.PolicyDescriptionCollection: """Lists all policy descriptions. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param scope: Policy scope. - :type scope: str or ~api_management_client.models.PolicyScopeContract + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDescriptionCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyDescriptionCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyDescriptionCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDescriptionCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDescriptionCollection] - request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, scope=scope, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,12 +111,11 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDescriptionCollection', pipeline_response) + deserialized = self._deserialize("PolicyDescriptionCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py index 730db8ebd4420..59792482e5990 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,102 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyOperations: - """PolicyOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.PolicyCollection": + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.PolicyCollection: """Lists all the Global Policy definitions of the Api Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -86,56 +109,64 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,59 +175,71 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @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"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the Global policy definition of the Api Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -205,70 +248,160 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PolicyContract', pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates the global policy configuration of the Api Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - _json = self._serialize.body(parameters, 'PolicyContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -278,67 +411,79 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -349,5 +494,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py index fbdf3b40ab1fb..97371ca84f58b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._portal_revision_operations import build_create_or_update_request_initial, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request_initial -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PortalRevisionOperations: - """PortalRevisionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PortalRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_revision` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,12 +71,12 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.PortalRevisionCollection"]: + ) -> AsyncIterable["_models.PortalRevisionContract"]: """Lists developer portal's revisions. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: .. list-table:: :header-rows: 1 @@ -75,27 +89,36 @@ def list_by_service( |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 | |. + |isCurrent | eq, ne | |. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PortalRevisionCollection or the result of + :return: An iterator like instance of either PortalRevisionContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.PortalRevisionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -103,24 +126,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +155,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,52 +167,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions"} # type: ignore @distributed_trace_async async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type portal_revision_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,56 +228,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - **kwargs: Any - ) -> "_models.PortalRevisionContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type portal_revision_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalRevisionContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalRevisionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalRevisionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -256,69 +293,170 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalRevisionContract', pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalRevisionContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PortalRevisionContract]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalRevisionContract", is_xml=True) + + 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, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PortalRevisionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -326,21 +464,24 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PortalRevisionContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type portal_revision_id: str - :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -352,54 +493,61 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PortalRevisionContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.PortalRevisionContract] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore async def _update_initial( self, @@ -407,53 +555,161 @@ async def _update_initial( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalRevisionContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PortalRevisionContract]] - request = build_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalRevisionContract", is_xml=True) + + 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PortalRevisionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -462,23 +718,26 @@ async def begin_update( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PortalRevisionContract"]: + ) -> AsyncLROPoller[_models.PortalRevisionContract]: """Updates the description of specified portal revision or makes it current. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -490,52 +749,59 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either PortalRevisionContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.PortalRevisionContract] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # 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 index cb531842816aa..5f0a43374b40b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._portal_settings_operations import build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PortalSettingsOperations: - """PortalSettingsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PortalSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSettingsCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingsCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSettingsCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSettingsCollection] - request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -86,12 +103,11 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSettingsCollection', pipeline_response) + deserialized = self._deserialize("PortalSettingsCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py index 85164a1dc335c..6b514d20bcf29 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connection_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_by_name_request, build_get_private_link_resource_request, build_list_by_service_request, build_list_private_link_resources_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionOperations: - """PrivateEndpointConnectionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.PrivateEndpointConnectionListResult"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - template_url=self.list_by_service.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +130,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,51 +142,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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, - template_url=self.get_by_name.metadata['url'], + api_version=api_version, + template_url=self.get_by_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -170,64 +201,162 @@ async def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO], **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection_request, 'PrivateEndpointConnectionRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection_request, (IO, 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, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -235,20 +364,23 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, - private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Creates a new Private Endpoint Connection or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: + :param private_endpoint_connection_request: Is either a model type or a IO type. Required. :type private_endpoint_connection_request: - ~api_management_client.models.PrivateEndpointConnectionRequest + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -260,104 +392,113 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + 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, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -369,80 +510,95 @@ async def begin_delete( Retry-After header is present. :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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def list_private_link_resources( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": - """Description for Gets the 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_private_link_resources_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, service_name=service_name, - template_url=self.list_private_link_resources.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -450,55 +606,63 @@ async def list_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources'} # type: ignore - + list_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources"} # 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": - """Description for Gets the private link resources. + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_link_sub_resource_name: Name of the private link resource. Required. :type private_link_sub_resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_private_link_resource_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, service_name=service_name, private_link_sub_resource_name=private_link_sub_resource_name, - template_url=self.get_private_link_resource.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -506,12 +670,11 @@ async def get_private_link_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_private_link_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}'} # type: ignore - + get_private_link_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py index ca2e8352d498e..a3bad436ae987 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._product_api_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_product_request -T = TypeVar('T') +from ...operations._product_api_operations import ( + build_check_entity_exists_request, + build_create_or_update_request, + build_delete_request, + build_list_by_product_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProductApiOperations: - """ProductApiOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,15 +69,15 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollection"]: + ) -> AsyncIterable["_models.ApiContract"]: """Lists a collection of the APIs associated with a product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -73,25 +86,34 @@ def list_by_product( |
| 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 |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -100,25 +122,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +151,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,57 +163,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis"} # type: ignore @distributed_trace_async async def check_entity_exists( - self, - resource_group_name: str, - service_name: str, - product_id: str, - api_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -204,54 +231,61 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -260,64 +294,71 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - product_id: str, - api_id: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -328,5 +369,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py index 94c57e93cf861..b81c9816288d9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._product_group_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_product_request -T = TypeVar('T') +from ...operations._product_group_operations import ( + build_check_entity_exists_request, + build_create_or_update_request, + build_delete_request, + build_list_by_product_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProductGroupOperations: - """ProductGroupOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,38 +69,47 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GroupCollection"]: + ) -> AsyncIterable["_models.GroupContract"]: """Lists the collection of developer groups associated with the specified product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 | |
. + description | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GroupCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -96,25 +118,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +147,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,57 +159,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups"} # type: ignore @distributed_trace_async async def check_entity_exists( - self, - resource_group_name: str, - service_name: str, - product_id: str, - group_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param group_id: Group identifier. Must be unique in the current API Management service - instance. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -200,54 +227,61 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param group_id: Group identifier. Must be unique in the current API Management service - instance. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -256,64 +290,71 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - product_id: str, - group_id: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param group_id: Group identifier. Must be unique in the current API Management service - instance. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -324,5 +365,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # 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 index b674f7c7d02eb..f848474ee7ca0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._product_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_by_tags_request, build_update_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProductOperations: - """ProductOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,12 +73,12 @@ def list_by_service( expand_groups: Optional[bool] = None, tags: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ProductCollection"]: + ) -> AsyncIterable["_models.ProductContract"]: """Lists a collection of products in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -70,31 +86,41 @@ def list_by_service( 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 | | |
. + endswith |
| state | filter | eq | |
| groups | expand | | |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :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. + 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. + :param tags: Products which are part of a specific tag. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductCollection or the result of cls(response) + :return: An iterator like instance of either ProductContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ProductCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -104,26 +130,22 @@ def prepare_request(next_link=None): skip=skip, expand_groups=expand_groups, tags=tags, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -137,7 +159,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,52 +171,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - product_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -201,56 +230,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - product_id: str, - **kwargs: Any - ) -> "_models.ProductContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -259,17 +295,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ProductContract', pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -277,53 +382,76 @@ async def create_or_update( resource_group_name: str, service_name: str, product_id: str, - parameters: "_models.ProductContract", + parameters: Union[_models.ProductContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Creates or Updates a product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ProductContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ProductContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -333,22 +461,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ProductContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ProductContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -357,52 +554,75 @@ async def update( service_name: str, product_id: str, if_match: str, - parameters: "_models.ProductUpdateParameters", + parameters: Union[_models.ProductUpdateParameters, IO], **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Update existing product details. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ProductUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductContract] - _json = self._serialize.body(parameters, 'ProductUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -411,20 +631,19 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ProductContract', pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -435,30 +654,38 @@ async def delete( ) -> None: """Delete product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -466,12 +693,18 @@ async def delete( subscription_id=self._config.subscription_id, if_match=if_match, delete_subscriptions=delete_subscriptions, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -482,8 +715,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace def list_by_tags( @@ -495,12 +727,12 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_products: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable["_models.TagResourceContract"]: """Lists a collection of products associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -509,28 +741,37 @@ def list_by_tags( |
| 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_products: Include not tagged Products. + :param include_not_tagged_products: Include not tagged Products. Default value is None. :type include_not_tagged_products: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) + :return: An iterator like instance of either TagResourceContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -539,25 +780,22 @@ def prepare_request(next_link=None): top=top, skip=skip, include_not_tagged_products=include_not_tagged_products, - template_url=self.list_by_tags.metadata['url'], + api_version=api_version, + template_url=self.list_by_tags.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -571,7 +809,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -581,8 +821,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags'} # type: ignore + list_by_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py index 1929f57392e9a..13c2a6590dfa0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,85 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._product_policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_product_request -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProductPolicyOperations: - """ProductPolicyOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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, - product_id: str, - **kwargs: Any - ) -> "_models.PolicyCollection": + self, resource_group_name: str, service_name: 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - 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, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -91,15 +113,14 @@ async def list_by_product( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies'} # type: ignore - + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -107,44 +128,57 @@ async def get_entity_tag( resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -153,15 +187,13 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace_async async def get( @@ -169,35 +201,43 @@ async def get( resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the Product level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -205,12 +245,18 @@ async def get( policy_id=policy_id, subscription_id=self._config.subscription_id, format=format, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -219,17 +265,92 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PolicyContract', pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -237,41 +358,57 @@ async def create_or_update( resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the Product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -279,15 +416,22 @@ async def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -297,59 +441,65 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -357,12 +507,18 @@ async def delete( policy_id=policy_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -373,5 +529,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # 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 index a258bb53ce26d..da4ba72efd559 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._product_subscriptions_operations import build_list_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProductSubscriptionsOperations: - """ProductSubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,15 +63,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionCollection"]: + ) -> AsyncIterable["_models.SubscriptionContract"]: """Lists the collection of subscriptions to the specified product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -76,27 +83,36 @@ def list( 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionCollection or the result of + :return: An iterator like instance of either SubscriptionContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SubscriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -105,25 +121,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -137,7 +150,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,8 +162,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py index 330c216fef8b0..c0dc11fc8e868 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,103 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._quota_by_counter_keys_operations import build_list_by_service_request, build_update_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class QuotaByCounterKeysOperations: - """QuotaByCounterKeysOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QuotaByCounterKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. :type quota_counter_key: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: QuotaCounterCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterCollection] - 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,15 +110,84 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -110,51 +195,75 @@ async def update( resource_group_name: str, service_name: str, quota_counter_key: str, - parameters: "_models.QuotaCounterValueUpdateContract", + parameters: Union[_models.QuotaCounterValueUpdateContract, IO], **kwargs: Any - ) -> "_models.QuotaCounterCollection": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: QuotaCounterCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterCollection] - _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,12 +271,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py index d3833e77f2a70..863d6d40f29df 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,92 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._quota_by_period_keys_operations import build_get_request, build_update_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class QuotaByPeriodKeysOperations: - """QuotaByPeriodKeysOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QuotaByPeriodKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + :param quota_period_key: Quota period key identifier. Required. :type quota_period_key: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: QuotaCounterContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,55 +113,145 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterContract', pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # 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. - @distributed_trace_async + :param resource_group_name: The name of the resource group. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.QuotaCounterValueUpdateContract", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.QuotaCounterContract": + ) -> _models.QuotaCounterContract: """Updates an existing quota counter value in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + :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. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract - :raises: ~azure.core.exceptions.HttpResponseError + :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], + **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. 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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterContract] - _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QuotaCounterValueUpdateContract") request = build_update_request( resource_group_name=resource_group_name, @@ -154,14 +259,21 @@ async def update( 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, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,12 +281,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterContract', pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py index 48c3f86af353b..b1b6b1b812595 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,92 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._region_operations import build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegionOperations: - """RegionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`region` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.RegionListResult"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.RegionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -104,7 +119,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,8 +131,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py index 385b86887fe24..597f0bd81f423 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,46 +7,61 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._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 -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReportsOperations: - """ReportsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,34 +73,45 @@ def list_by_api( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable["_models.ReportRecordContract"]: """Lists report records by API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -93,25 +120,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +149,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -135,11 +161,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi"} # type: ignore @distributed_trace def list_by_user( @@ -151,12 +175,12 @@ def list_by_user( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable["_models.ReportRecordContract"]: """Lists report records by User. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -171,26 +195,38 @@ def list_by_user(
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -199,25 +235,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_user.metadata['url'], + api_version=api_version, + template_url=self.list_by_user.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -231,7 +264,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,11 +276,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore + list_by_user.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser"} # type: ignore @distributed_trace def list_by_operation( @@ -257,12 +290,12 @@ def list_by_operation( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable["_models.ReportRecordContract"]: """Lists report records by API Operations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -277,26 +310,38 @@ def list_by_operation(
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -305,25 +350,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_operation.metadata['url'], + api_version=api_version, + template_url=self.list_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -337,7 +379,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,11 +391,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore + list_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation"} # type: ignore @distributed_trace def list_by_product( @@ -363,12 +405,12 @@ def list_by_product( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable["_models.ReportRecordContract"]: """Lists report records by Product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -382,26 +424,38 @@ def list_by_product(
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -410,25 +464,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -442,7 +493,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,11 +505,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct"} # type: ignore @distributed_trace def list_by_geo( @@ -467,12 +518,12 @@ def list_by_geo( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable["_models.ReportRecordContract"]: """Lists report records by geography. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -486,25 +537,36 @@ def list_by_geo( cacheMissCount | select | | |
| apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| - serviceTimeMax | select | | |
. + serviceTimeMax | select | | |
. Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -512,24 +574,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_geo.metadata['url'], + api_version=api_version, + template_url=self.list_by_geo.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -543,7 +603,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -553,11 +615,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore + list_by_geo.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo"} # type: ignore @distributed_trace def list_by_subscription( @@ -569,12 +629,12 @@ def list_by_subscription( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable["_models.ReportRecordContract"]: """Lists report records by subscription. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -588,26 +648,38 @@ def list_by_subscription( |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -616,25 +688,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -648,7 +717,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -658,11 +729,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription"} # type: ignore @distributed_trace def list_by_time( @@ -675,12 +744,12 @@ def list_by_time( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable["_models.ReportRecordContract"]: """Lists report records by Time. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -693,32 +762,43 @@ def list_by_time( cacheHitsCount | select | | |
| cacheMissCount | select | | |
| apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | - select | | |
| serviceTimeMax | select | | |
. + 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)). + TimeSpan(hours, minutes, seconds)). Required. :type interval: ~datetime.timedelta - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -728,26 +808,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_time.metadata['url'], + api_version=api_version, + template_url=self.list_by_time.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -761,7 +837,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -771,11 +849,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore + list_by_time.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime"} # type: ignore @distributed_trace def list_by_request( @@ -786,38 +862,47 @@ def list_by_request( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.RequestReportCollection"]: + ) -> AsyncIterable["_models.RequestReportRecordContract"]: """Lists report records by Request. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + filter | eq | |
| subscriptionId | filter | eq | |
. Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RequestReportCollection or the result of + :return: An iterator like instance of either RequestReportRecordContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.RequestReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RequestReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RequestReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -825,24 +910,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_request.metadata['url'], + api_version=api_version, + template_url=self.list_by_request.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -856,7 +939,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -866,8 +951,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_request.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest'} # type: ignore + list_by_request.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py index 7a1093beb971c..93907a525c32b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,99 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sign_in_settings_operations import build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_update_request -T = TypeVar('T') +from ...operations._sign_in_settings_operations import ( + build_create_or_update_request, + build_get_entity_tag_request, + build_get_request, + build_update_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignInSettingsOperations: - """SignInSettingsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignInSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,51 +107,57 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalSigninSettings": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSigninSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSigninSettings] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,66 +166,150 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalSigninSettings', pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore + @overload + async def update( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + if_match: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def update( + async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSigninSettings", + parameters: Union[_models.PortalSigninSettings, IO], **kwargs: Any ) -> None: """Update Sign-In settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update Sign-In settings. - :type parameters: ~api_management_client.models.PortalSigninSettings + :param parameters: Update Sign-In settings. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalSigninSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSigninSettings", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -210,57 +320,141 @@ async def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PortalSigninSettings", + parameters: Union[_models.PortalSigninSettings, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSigninSettings": + ) -> _models.PortalSigninSettings: """Create or Update Sign-In settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSigninSettings + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSigninSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSigninSettings] - _json = self._serialize.body(parameters, 'PortalSigninSettings') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSigninSettings", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -268,12 +462,11 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSigninSettings', pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py index 37588cdb4399f..be609ef5bb1b1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,99 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sign_up_settings_operations import build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_update_request -T = TypeVar('T') +from ...operations._sign_up_settings_operations import ( + build_create_or_update_request, + build_get_entity_tag_request, + build_get_request, + build_update_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignUpSettingsOperations: - """SignUpSettingsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignUpSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,51 +107,57 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalSignupSettings": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSignupSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSignupSettings] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,66 +166,150 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalSignupSettings', pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore + @overload + async def update( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + if_match: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def update( + async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSignupSettings", + parameters: Union[_models.PortalSignupSettings, IO], **kwargs: Any ) -> None: """Update Sign-Up settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update Sign-Up settings. - :type parameters: ~api_management_client.models.PortalSignupSettings + :param parameters: Update Sign-Up settings. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalSignupSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSignupSettings", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -210,57 +320,141 @@ async def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PortalSignupSettings", + parameters: Union[_models.PortalSignupSettings, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSignupSettings": + ) -> _models.PortalSignupSettings: """Create or Update Sign-Up settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSignupSettings + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSignupSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSignupSettings] - _json = self._serialize.body(parameters, 'PortalSignupSettings') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSignupSettings", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -268,12 +462,11 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSignupSettings', pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py index 247563b8f3ab4..4dc181ec78ae8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscription_operations import build_create_or_update_request, build_delete_request, 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 -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SubscriptionOperations: - """SubscriptionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,12 +73,12 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionCollection"]: + ) -> AsyncIterable["_models.SubscriptionContract"]: """Lists all subscriptions of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -72,27 +90,36 @@ def list( 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionCollection or the result of + :return: An iterator like instance of either SubscriptionContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SubscriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -100,24 +127,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +156,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,53 +168,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,56 +228,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any - ) -> "_models.SubscriptionContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -254,17 +293,110 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -272,66 +404,90 @@ async def create_or_update( resource_group_name: str, service_name: str, sid: str, - parameters: "_models.SubscriptionCreateParameters", + parameters: Union[_models.SubscriptionCreateParameters, IO], notify: Optional[bool] = None, if_match: Optional[str] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Creates or updates the subscription of specified user to the specified product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.SubscriptionCreateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or IO :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. + * 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. + 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. - :type app_type: str or ~api_management_client.models.AppType + 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. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] - _json = self._serialize.body(parameters, 'SubscriptionCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, - json=_json, notify=notify, if_match=if_match, app_type=app_type, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -341,22 +497,115 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -365,65 +614,89 @@ async def update( service_name: str, sid: str, if_match: str, - parameters: "_models.SubscriptionUpdateParameters", + parameters: Union[_models.SubscriptionUpdateParameters, IO], notify: Optional[bool] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Updates the details of a subscription specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.SubscriptionUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or IO :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. + * 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. - :type app_type: str or ~api_management_client.models.AppType + 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. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] - _json = self._serialize.body(parameters, 'SubscriptionUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, - json=_json, notify=notify, app_type=app_type, - template_url=self.update.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -432,63 +705,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - sid: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -499,49 +779,57 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async - async def regenerate_primary_key( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.regenerate_primary_key.metadata['url'], + api_version=api_version, + template_url=self.regenerate_primary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -552,49 +840,57 @@ async def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey'} # type: ignore - + regenerate_primary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey"} # type: ignore @distributed_trace_async - async def regenerate_secondary_key( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.regenerate_secondary_key.metadata['url'], + api_version=api_version, + template_url=self.regenerate_secondary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -605,49 +901,57 @@ async def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey'} # type: ignore - + regenerate_secondary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey"} # type: ignore @distributed_trace_async async def list_secrets( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any - ) -> "_models.SubscriptionKeysContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionKeysContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionKeysContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionKeysContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionKeysContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,14 +960,13 @@ async def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionKeysContract', pipeline_response) + deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py index 5c4d59e3d95bb..100499a05a511 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,75 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._tag_operations import build_assign_to_api_request, build_assign_to_operation_request, 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 -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TagOperations: - """TagOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -57,41 +87,51 @@ def list_by_operation( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable["_models.TagContract"]: """Lists all Tags associated with the Operation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -101,26 +141,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_operation.metadata['url'], + api_version=api_version, + template_url=self.list_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +170,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,48 +182,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags'} # type: ignore + list_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_state_by_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -193,12 +231,18 @@ async def get_entity_state_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_state_by_operation.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,52 +251,52 @@ async def get_entity_state_by_operation( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + get_entity_state_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - request = build_get_by_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -260,12 +304,18 @@ async def get_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.get_by_operation.metadata['url'], + api_version=api_version, + template_url=self.get_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -274,54 +324,55 @@ async def get_by_operation( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + get_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - request = build_assign_to_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -329,12 +380,18 @@ async def assign_to_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.assign_to_operation.metadata['url'], + api_version=api_version, + template_url=self.assign_to_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,55 +400,56 @@ async def assign_to_operation( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - assign_to_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + assign_to_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_detach_from_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -399,12 +457,18 @@ async def detach_from_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.detach_from_operation.metadata['url'], + api_version=api_version, + template_url=self.detach_from_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -415,8 +479,7 @@ async def detach_from_operation( if cls: return cls(pipeline_response, None, {}) - detach_from_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + detach_from_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace def list_by_api( @@ -428,38 +491,48 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable["_models.TagContract"]: """Lists all Tags associated with the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -468,25 +541,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -500,7 +570,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -510,56 +582,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_state_by_api.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,60 +647,67 @@ async def get_entity_state_by_api( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + get_entity_state_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.get_by_api.metadata['url'], + api_version=api_version, + template_url=self.get_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -630,62 +716,70 @@ async def get_by_api( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + get_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.assign_to_api.metadata['url'], + api_version=api_version, + template_url=self.assign_to_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -695,67 +789,75 @@ async def assign_to_api( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - assign_to_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + assign_to_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.detach_from_api.metadata['url'], + api_version=api_version, + template_url=self.detach_from_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -766,8 +868,7 @@ async def detach_from_api( if cls: return cls(pipeline_response, None, {}) - detach_from_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + detach_from_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace def list_by_product( @@ -779,38 +880,48 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable["_models.TagContract"]: """Lists all Tags associated with the Product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -819,25 +930,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -851,7 +959,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -861,56 +971,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_state_by_product.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -919,60 +1036,67 @@ async def get_entity_state_by_product( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + get_entity_state_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.get_by_product.metadata['url'], + api_version=api_version, + template_url=self.get_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -981,62 +1105,70 @@ async def get_by_product( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + get_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.assign_to_product.metadata['url'], + api_version=api_version, + template_url=self.assign_to_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1045,63 +1177,71 @@ async def assign_to_product( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - assign_to_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + assign_to_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.detach_from_product.metadata['url'], + api_version=api_version, + template_url=self.detach_from_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1112,8 +1252,7 @@ async def detach_from_product( if cls: return cls(pipeline_response, None, {}) - detach_from_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + detach_from_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace def list_by_service( @@ -1125,38 +1264,47 @@ def list_by_service( skip: Optional[int] = None, scope: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable["_models.TagContract"]: """Lists a collection of tags defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -1165,25 +1313,22 @@ def prepare_request(next_link=None): top=top, skip=skip, scope=scope, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1197,7 +1342,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1207,51 +1354,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags"} # type: ignore @distributed_trace_async - async def get_entity_state( - self, - resource_group_name: str, - service_name: str, - tag_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_state.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1260,55 +1413,61 @@ async def get_entity_state( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore - + get_entity_state.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - service_name: str, - tag_id: str, - **kwargs: Any - ) -> "_models.TagContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1317,17 +1476,86 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -1335,52 +1563,76 @@ async def create_or_update( resource_group_name: str, service_name: str, tag_id: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: Union[_models.TagCreateUpdateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Creates a tag. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1390,22 +1642,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -1414,51 +1735,75 @@ async def update( service_name: str, tag_id: str, if_match: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: Union[_models.TagCreateUpdateParameters, IO], **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Updates the details of the tag specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1467,62 +1812,70 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - service_name: str, - tag_id: str, - if_match: str, - **kwargs: Any + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1533,5 +1886,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py index 1d905815a541f..1e4577c4b1e5c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tag_resource_operations import build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TagResourceOperations: - """TagResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagResourceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -55,12 +62,12 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable["_models.TagResourceContract"]: """Lists a collection of resources associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| aid | @@ -76,27 +83,35 @@ def list_by_service( 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 | |
. + | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) + :return: An iterator like instance of either TagResourceContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -104,24 +119,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +148,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,8 +160,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py index 802ddf006e4eb..cb516bbd5c3e8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,103 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._tenant_access_git_operations import build_regenerate_primary_key_request, build_regenerate_secondary_key_request -T = TypeVar('T') +from ...operations._tenant_access_git_operations import ( + build_regenerate_primary_key_request, + build_regenerate_secondary_key_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantAccessGitOperations: - """TenantAccessGitOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantAccessGitOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_primary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_primary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_primary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -93,48 +113,57 @@ async def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey'} # type: ignore - + regenerate_primary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_secondary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_secondary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_secondary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -145,5 +174,4 @@ async def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey'} # type: ignore - + regenerate_secondary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey"} # 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 index 310e0cda7e5bf..20c7fd93b2a12 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,120 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._tenant_access_operations import build_create_request, build_get_entity_tag_request, 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 -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantAccessOperations: - """TenantAccessOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantAccessOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_access` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.AccessInformationCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param filter: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessInformationCollection or the result of + :return: An iterator like instance of either AccessInformationContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.AccessInformationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AccessInformationContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +133,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,51 +145,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.get_entity_tag.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,55 +206,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, "_models.AccessIdName"], - **kwargs: Any - ) -> "_models.AccessInformationContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -231,70 +271,164 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationContract', pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information details. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + access_name: Union[str, _models.AccessIdName], if_match: str, - parameters: "_models.AccessInformationCreateParameters", + parameters: Union[_models.AccessInformationCreateParameters, IO], **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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. + 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. - :type parameters: ~api_management_client.models.AccessInformationCreateParameters + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'AccessInformationCreateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,70 +437,164 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationContract', pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information details. + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + access_name: Union[str, _models.AccessIdName], if_match: str, - parameters: "_models.AccessInformationUpdateParameters", + parameters: Union[_models.AccessInformationUpdateParameters, IO], **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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. + 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. - :type parameters: ~api_management_client.models.AccessInformationUpdateParameters + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'AccessInformationUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,57 +603,66 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationContract', pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_primary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_primary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_primary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -436,48 +673,57 @@ async def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey'} # type: ignore - + regenerate_primary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey"} # 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 + async 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_secondary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_secondary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_secondary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -488,48 +734,57 @@ async def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey'} # type: ignore - + regenerate_secondary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationSecretsContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationSecretsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationSecretsContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationSecretsContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.list_secrets.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,14 +793,13 @@ async def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationSecretsContract', pipeline_response) + deserialized = self._deserialize("AccessInformationSecretsContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py index 6407d2097f130..0d3bba234873c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,234 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tenant_configuration_operations import build_deploy_request_initial, build_get_sync_state_request, build_save_request_initial, build_validate_request_initial -T = TypeVar('T') +from ...operations._tenant_configuration_operations import ( + build_deploy_request, + build_get_sync_state_request, + build_save_request, + build_validate_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantConfigurationOperations: - """TenantConfigurationOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResultContract]] - _json = self._serialize.body(parameters, 'DeployConfigurationParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeployConfigurationParameters") - request = build_deploy_request_initial( + request = build_deploy_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._deploy_initial.metadata['url'], + content=_content, + template_url=self._deploy_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _deploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + _deploy_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OperationResultContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName - :param parameters: Deploy Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -126,121 +245,234 @@ async def begin_deploy( :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.OperationResultContract] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._deploy_initial( + raw_result = await self._deploy_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_deploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + begin_deploy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # type: ignore async def _save_initial( self, resource_group_name: str, service_name: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.SaveConfigurationParameter", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, IO], **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SaveConfigurationParameter') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResultContract]] - request = build_save_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SaveConfigurationParameter") + + request = build_save_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._save_initial.metadata['url'], + content=_content, + template_url=self._save_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _save_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + _save_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.SaveConfigurationParameter", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OperationResultContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName - :param parameters: Save Configuration parameters. - :type parameters: ~api_management_client.models.SaveConfigurationParameter + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -252,121 +484,234 @@ async def begin_save( :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.OperationResultContract] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._save_initial( + raw_result = await self._save_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_save.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + begin_save.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResultContract]] - _json = self._serialize.body(parameters, 'DeployConfigurationParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeployConfigurationParameters") - request = build_validate_request_initial( + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OperationResultContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName - :param parameters: Validate Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -378,92 +723,112 @@ async def begin_validate( :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.OperationResultContract] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_initial( + raw_result = await self._validate_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # type: ignore @distributed_trace_async async def get_sync_state( self, resource_group_name: str, service_name: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], + configuration_name: Union[str, _models.ConfigurationIdName], **kwargs: Any - ) -> "_models.TenantConfigurationSyncStateContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :param configuration_name: The identifier of the Git Configuration Operation. "configuration" + Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantConfigurationSyncStateContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantConfigurationSyncStateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TenantConfigurationSyncStateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantConfigurationSyncStateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantConfigurationSyncStateContract] - request = build_get_sync_state_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, - template_url=self.get_sync_state.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_sync_state.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -471,12 +836,11 @@ async def get_sync_state( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TenantConfigurationSyncStateContract', pipeline_response) + deserialized = self._deserialize("TenantConfigurationSyncStateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_sync_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState'} # type: ignore - + get_sync_state.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py index 942d49f3f2d56..d6beba7491583 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_settings_operations import build_get_request, build_list_by_service_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantSettingsOperations: - """TenantSettingsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.TenantSettingsCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param filter: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantSettingsCollection or the result of + :return: An iterator like instance of either TenantSettingsContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TenantSettingsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantSettingsCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +124,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,51 +136,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings"} # type: ignore @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, - settings_type: Union[str, "_models.SettingsTypeName"], + settings_type: Union[str, _models.SettingsTypeName], **kwargs: Any - ) -> "_models.TenantSettingsContract": + ) -> _models.TenantSettingsContract: """Get tenant settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param settings_type: The identifier of the settings. - :type settings_type: str or ~api_management_client.models.SettingsTypeName + :param settings_type: The identifier of the settings. "public" Required. + :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantSettingsContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantSettingsContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TenantSettingsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantSettingsContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, settings_type=settings_type, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,14 +200,13 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TenantSettingsContract', pipeline_response) + deserialized = self._deserialize("TenantSettingsContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py index 77393221ff69c..386d95350655d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,89 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_confirmation_password_operations import build_send_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UserConfirmationPasswordOperations: - """UserConfirmationPasswordOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserConfirmationPasswordOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( + async 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, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> None: """Sends confirmation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type app_type: str or ~api_management_client.models.AppType + 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 callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.send.metadata['url'], + api_version=api_version, + template_url=self.send.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -98,5 +120,4 @@ async def send( if cls: return cls(pipeline_response, None, {}) - send.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send'} # type: ignore - + send.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send"} # 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 index 999bdde3666bf..8fa26e0d1ba25 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_group_operations import build_list_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UserGroupOperations: - """UserGroupOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,14 +63,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GroupCollection"]: + ) -> AsyncIterable["_models.GroupContract"]: """Lists all user groups. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 @@ -71,25 +79,34 @@ def list( 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 |
. + endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GroupCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -98,25 +115,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,7 +144,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,8 +156,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py index 8f42f24c06d6c..87c6a04852740 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_identities_operations import build_list_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UserIdentitiesOperations: - """UserIdentitiesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.UserIdentityCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserIdentityCollection or the result of + :return: An iterator like instance of either UserIdentityContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.UserIdentityCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserIdentityContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserIdentityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserIdentityCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +124,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py index f51f16963a159..22d7637d21437 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,62 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._user_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 -T = TypeVar('T') +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, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UserOperations: - """UserOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,12 +73,12 @@ def list_by_service( skip: Optional[int] = None, expand_groups: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.UserCollection"]: + ) -> AsyncIterable["_models.UserContract"]: """Lists a collection of registered users in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -71,27 +88,36 @@ def list_by_service( |
| 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 | | |
. + |
| groups | expand | | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param expand_groups: Detailed Group in response. + :param expand_groups: Detailed Group in response. Default value is None. :type expand_groups: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.UserCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -100,25 +126,22 @@ def prepare_request(next_link=None): top=top, skip=skip, expand_groups=expand_groups, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +155,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,51 +167,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users"} # type: ignore @distributed_trace_async - async def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - user_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,55 +226,63 @@ async def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - user_id: str, - **kwargs: Any - ) -> "_models.UserContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,17 +291,92 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -270,56 +384,80 @@ async def create_or_update( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserCreateParameters", + parameters: Union[_models.UserCreateParameters, IO], notify: Optional[bool] = None, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Creates or Updates a user. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.UserCreateParameters - :param notify: Send an Email notification to the User. + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters or IO + :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. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] - _json = self._serialize.body(parameters, 'UserCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, - json=_json, notify=notify, if_match=if_match, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -329,22 +467,91 @@ async def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('UserContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("UserContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('UserContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -353,51 +560,75 @@ async def update( service_name: str, user_id: str, if_match: str, - parameters: "_models.UserUpdateParameters", + parameters: Union[_models.UserUpdateParameters, IO], **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Updates the details of the user specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.UserUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'UserUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,20 +637,19 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -427,39 +657,49 @@ async def delete( if_match: str, delete_subscriptions: Optional[bool] = None, notify: Optional[bool] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> None: """Deletes specific user. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + :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. + :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. - :type app_type: str or ~api_management_client.models.AppType + 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 callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -469,12 +709,18 @@ async def delete( delete_subscriptions=delete_subscriptions, notify=notify, app_type=app_type, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -485,49 +731,58 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: GenerateSsoUrlResult, or the result of cls(response) - :rtype: ~api_management_client.models.GenerateSsoUrlResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: GenerateSsoUrlResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateSsoUrlResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenerateSsoUrlResult] - 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, - template_url=self.generate_sso_url.metadata['url'], + api_version=api_version, + template_url=self.generate_sso_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,15 +790,76 @@ async def generate_sso_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateSsoUrlResult', pipeline_response) + deserialized = self._deserialize("GenerateSsoUrlResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_sso_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl'} # type: ignore + generate_sso_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -551,47 +867,72 @@ async def get_shared_access_token( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserTokenParameters", + parameters: Union[_models.UserTokenParameters, IO], **kwargs: Any - ) -> "_models.UserTokenResult": + ) -> _models.UserTokenResult: """Gets the Shared Access Authorization Token for the User. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.UserTokenParameters + :param parameters: Create Authorization Token parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.UserTokenResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserTokenResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserTokenResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserTokenResult] - _json = self._serialize.body(parameters, 'UserTokenParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.get_shared_access_token.metadata['url'], + content=_content, + template_url=self.get_shared_access_token.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -599,12 +940,11 @@ async def get_shared_access_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserTokenResult', pipeline_response) + deserialized = self._deserialize("UserTokenResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_shared_access_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token'} # type: ignore - + get_shared_access_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py index 91eadd808aedd..0763a2e5222ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_subscription_operations import build_get_request, build_list_request -T = TypeVar('T') +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UserSubscriptionOperations: - """UserSubscriptionOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserSubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -56,14 +64,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionCollection"]: + ) -> AsyncIterable["_models.SubscriptionContract"]: """Lists the collection of subscriptions of the specified user. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | @@ -74,27 +83,36 @@ def list( 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 |
. + contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionCollection or the result of + :return: An iterator like instance of either SubscriptionContract or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SubscriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -103,25 +121,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +150,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,56 +162,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - service_name: str, - user_id: str, - sid: str, - **kwargs: Any - ) -> "_models.SubscriptionContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,14 +227,13 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}"} # 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 d83a3cafb3e34..1b2f6163a2392 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 @@ -303,443 +303,445 @@ from ._models_py3 import VirtualNetworkConfiguration from ._models_py3 import X509CertificateName - -from ._api_management_client_enums import ( - AccessIdName, - AccessType, - AlwaysLog, - ApiManagementSkuCapacityScaleType, - ApiManagementSkuRestrictionsReasonCode, - ApiManagementSkuRestrictionsType, - ApiType, - ApiVersionSetContractDetailsVersioningScheme, - ApimIdentityType, - AppType, - AsyncOperationStatus, - AuthorizationMethod, - BackendProtocol, - BearerTokenSendingMethod, - BearerTokenSendingMethods, - CertificateConfigurationStoreName, - CertificateSource, - CertificateStatus, - ClientAuthenticationMethod, - ConfigurationIdName, - Confirmation, - ConnectionStatus, - ConnectivityCheckProtocol, - ConnectivityStatusType, - ContentFormat, - CreatedByType, - DataMaskingMode, - ExportApi, - ExportFormat, - ExportResultFormat, - GrantType, - GroupType, - HostnameType, - HttpCorrelationProtocol, - IdentityProviderType, - IssueType, - KeyType, - LoggerType, - Method, - NameAvailabilityReason, - NotificationName, - OperationNameFormat, - Origin, - PlatformVersion, - PolicyContentFormat, - PolicyExportFormat, - PolicyIdName, - PolicyScopeContract, - PortalRevisionStatus, - PreferredIPVersion, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProductState, - Protocol, - PublicNetworkAccess, - ResourceSkuCapacityScaleType, - SamplingType, - SchemaType, - SettingsTypeName, - Severity, - SkuType, - SoapApiType, - State, - SubscriptionState, - TemplateName, - UserState, - Verbosity, - VersioningScheme, - VirtualNetworkType, -) +from ._api_management_client_enums import AccessIdName +from ._api_management_client_enums import AccessType +from ._api_management_client_enums import AlwaysLog +from ._api_management_client_enums import ApiManagementSkuCapacityScaleType +from ._api_management_client_enums import ApiManagementSkuRestrictionsReasonCode +from ._api_management_client_enums import ApiManagementSkuRestrictionsType +from ._api_management_client_enums import ApiType +from ._api_management_client_enums import ApiVersionSetContractDetailsVersioningScheme +from ._api_management_client_enums import ApimIdentityType +from ._api_management_client_enums import AppType +from ._api_management_client_enums import AsyncOperationStatus +from ._api_management_client_enums import AuthorizationMethod +from ._api_management_client_enums import BackendProtocol +from ._api_management_client_enums import BearerTokenSendingMethod +from ._api_management_client_enums import BearerTokenSendingMethods +from ._api_management_client_enums import CertificateConfigurationStoreName +from ._api_management_client_enums import CertificateSource +from ._api_management_client_enums import CertificateStatus +from ._api_management_client_enums import ClientAuthenticationMethod +from ._api_management_client_enums import ConfigurationIdName +from ._api_management_client_enums import Confirmation +from ._api_management_client_enums import ConnectionStatus +from ._api_management_client_enums import ConnectivityCheckProtocol +from ._api_management_client_enums import ConnectivityStatusType +from ._api_management_client_enums import ContentFormat +from ._api_management_client_enums import CreatedByType +from ._api_management_client_enums import DataMaskingMode +from ._api_management_client_enums import ExportApi +from ._api_management_client_enums import ExportFormat +from ._api_management_client_enums import ExportResultFormat +from ._api_management_client_enums import GrantType +from ._api_management_client_enums import GroupType +from ._api_management_client_enums import HostnameType +from ._api_management_client_enums import HttpCorrelationProtocol +from ._api_management_client_enums import IdentityProviderType +from ._api_management_client_enums import IssueType +from ._api_management_client_enums import KeyType +from ._api_management_client_enums import LoggerType +from ._api_management_client_enums import Method +from ._api_management_client_enums import NameAvailabilityReason +from ._api_management_client_enums import NotificationName +from ._api_management_client_enums import OperationNameFormat +from ._api_management_client_enums import Origin +from ._api_management_client_enums import PlatformVersion +from ._api_management_client_enums import PolicyContentFormat +from ._api_management_client_enums import PolicyExportFormat +from ._api_management_client_enums import PolicyIdName +from ._api_management_client_enums import PolicyScopeContract +from ._api_management_client_enums import PortalRevisionStatus +from ._api_management_client_enums import PreferredIPVersion +from ._api_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._api_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._api_management_client_enums import ProductState +from ._api_management_client_enums import Protocol +from ._api_management_client_enums import PublicNetworkAccess +from ._api_management_client_enums import ResourceSkuCapacityScaleType +from ._api_management_client_enums import SamplingType +from ._api_management_client_enums import SchemaType +from ._api_management_client_enums import SettingsTypeName +from ._api_management_client_enums import Severity +from ._api_management_client_enums import SkuType +from ._api_management_client_enums import SoapApiType +from ._api_management_client_enums import State +from ._api_management_client_enums import SubscriptionState +from ._api_management_client_enums import TemplateName +from ._api_management_client_enums import UserState +from ._api_management_client_enums import Verbosity +from ._api_management_client_enums import VersioningScheme +from ._api_management_client_enums import VirtualNetworkType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AccessInformationCollection', - 'AccessInformationContract', - 'AccessInformationCreateParameters', - 'AccessInformationSecretsContract', - 'AccessInformationUpdateParameters', - 'AdditionalLocation', - 'ApiCollection', - 'ApiContactInformation', - 'ApiContract', - 'ApiContractProperties', - 'ApiContractUpdateProperties', - 'ApiCreateOrUpdateParameter', - 'ApiCreateOrUpdateProperties', - 'ApiCreateOrUpdatePropertiesWsdlSelector', - 'ApiEntityBaseContract', - 'ApiExportResult', - 'ApiExportResultValue', - 'ApiLicenseInformation', - 'ApiManagementServiceApplyNetworkConfigurationParameters', - 'ApiManagementServiceBackupRestoreParameters', - 'ApiManagementServiceBaseProperties', - 'ApiManagementServiceCheckNameAvailabilityParameters', - 'ApiManagementServiceGetDomainOwnershipIdentifierResult', - 'ApiManagementServiceGetSsoTokenResult', - 'ApiManagementServiceIdentity', - 'ApiManagementServiceListResult', - 'ApiManagementServiceNameAvailabilityResult', - 'ApiManagementServiceProperties', - 'ApiManagementServiceResource', - 'ApiManagementServiceSkuProperties', - 'ApiManagementServiceUpdateParameters', - 'ApiManagementServiceUpdateProperties', - 'ApiManagementSku', - 'ApiManagementSkuCapabilities', - 'ApiManagementSkuCapacity', - 'ApiManagementSkuCosts', - 'ApiManagementSkuLocationInfo', - 'ApiManagementSkuRestrictionInfo', - 'ApiManagementSkuRestrictions', - 'ApiManagementSkuZoneDetails', - 'ApiManagementSkusResult', - 'ApiReleaseCollection', - 'ApiReleaseContract', - 'ApiRevisionCollection', - 'ApiRevisionContract', - 'ApiRevisionInfoContract', - 'ApiTagResourceContractProperties', - 'ApiUpdateContract', - 'ApiVersionConstraint', - 'ApiVersionSetCollection', - 'ApiVersionSetContract', - 'ApiVersionSetContractDetails', - 'ApiVersionSetContractProperties', - 'ApiVersionSetEntityBase', - 'ApiVersionSetUpdateParameters', - 'ApiVersionSetUpdateParametersProperties', - 'ApimResource', - 'ArmIdWrapper', - 'AssociationContract', - 'AuthenticationSettingsContract', - 'AuthorizationServerCollection', - 'AuthorizationServerContract', - 'AuthorizationServerContractBaseProperties', - 'AuthorizationServerContractProperties', - 'AuthorizationServerSecretsContract', - 'AuthorizationServerUpdateContract', - 'AuthorizationServerUpdateContractProperties', - 'BackendAuthorizationHeaderCredentials', - 'BackendBaseParameters', - 'BackendCollection', - 'BackendContract', - 'BackendContractProperties', - 'BackendCredentialsContract', - 'BackendProperties', - 'BackendProxyContract', - 'BackendReconnectContract', - 'BackendServiceFabricClusterProperties', - 'BackendTlsProperties', - 'BackendUpdateParameterProperties', - 'BackendUpdateParameters', - 'BodyDiagnosticSettings', - 'CacheCollection', - 'CacheContract', - 'CacheUpdateParameters', - 'CertificateCollection', - 'CertificateConfiguration', - 'CertificateContract', - 'CertificateCreateOrUpdateParameters', - 'CertificateInformation', - 'ClientSecretContract', - 'ConnectivityCheckRequest', - 'ConnectivityCheckRequestDestination', - 'ConnectivityCheckRequestProtocolConfiguration', - 'ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration', - 'ConnectivityCheckRequestSource', - 'ConnectivityCheckResponse', - 'ConnectivityHop', - 'ConnectivityIssue', - 'ConnectivityStatusContract', - 'ContentItemCollection', - 'ContentItemContract', - 'ContentTypeCollection', - 'ContentTypeContract', - 'DataMasking', - 'DataMaskingEntity', - 'DeletedServiceContract', - 'DeletedServicesCollection', - 'DeployConfigurationParameters', - 'DiagnosticCollection', - 'DiagnosticContract', - 'EmailTemplateCollection', - 'EmailTemplateContract', - 'EmailTemplateParametersContractProperties', - 'EmailTemplateUpdateParameters', - 'EndpointDependency', - 'EndpointDetail', - 'ErrorFieldContract', - 'ErrorResponse', - 'ErrorResponseBody', - 'GatewayCertificateAuthorityCollection', - 'GatewayCertificateAuthorityContract', - 'GatewayCollection', - 'GatewayContract', - 'GatewayHostnameConfigurationCollection', - 'GatewayHostnameConfigurationContract', - 'GatewayKeyRegenerationRequestContract', - 'GatewayKeysContract', - 'GatewayTokenContract', - 'GatewayTokenRequestContract', - 'GenerateSsoUrlResult', - 'GlobalSchemaCollection', - 'GlobalSchemaContract', - 'GroupCollection', - 'GroupContract', - 'GroupContractProperties', - 'GroupCreateParameters', - 'GroupUpdateParameters', - 'HTTPHeader', - 'HostnameConfiguration', - 'HttpMessageDiagnostic', - 'IdentityProviderBaseParameters', - 'IdentityProviderContract', - 'IdentityProviderContractProperties', - 'IdentityProviderCreateContract', - 'IdentityProviderCreateContractProperties', - 'IdentityProviderList', - 'IdentityProviderUpdateParameters', - 'IdentityProviderUpdateProperties', - 'IssueAttachmentCollection', - 'IssueAttachmentContract', - 'IssueCollection', - 'IssueCommentCollection', - 'IssueCommentContract', - 'IssueContract', - 'IssueContractBaseProperties', - 'IssueContractProperties', - 'IssueUpdateContract', - 'IssueUpdateContractProperties', - 'KeyVaultContractCreateProperties', - 'KeyVaultContractProperties', - 'KeyVaultLastAccessStatusContractProperties', - 'LoggerCollection', - 'LoggerContract', - 'LoggerUpdateContract', - 'NamedValueCollection', - 'NamedValueContract', - 'NamedValueContractProperties', - 'NamedValueCreateContract', - 'NamedValueCreateContractProperties', - 'NamedValueEntityBaseParameters', - 'NamedValueSecretContract', - 'NamedValueUpdateParameterProperties', - 'NamedValueUpdateParameters', - 'NetworkStatusContract', - 'NetworkStatusContractByLocation', - 'NotificationCollection', - 'NotificationContract', - 'OAuth2AuthenticationSettingsContract', - 'OpenIdAuthenticationSettingsContract', - 'OpenIdConnectProviderCollection', - 'OpenidConnectProviderContract', - 'OpenidConnectProviderUpdateContract', - 'Operation', - 'OperationCollection', - 'OperationContract', - 'OperationContractProperties', - 'OperationDisplay', - 'OperationEntityBaseContract', - 'OperationListResult', - 'OperationResultContract', - 'OperationResultLogItemContract', - 'OperationTagResourceContractProperties', - 'OperationUpdateContract', - 'OperationUpdateContractProperties', - 'OutboundEnvironmentEndpoint', - 'OutboundEnvironmentEndpointList', - 'ParameterContract', - 'ParameterExampleContract', - 'PipelineDiagnosticSettings', - 'PolicyCollection', - 'PolicyContract', - 'PolicyDescriptionCollection', - 'PolicyDescriptionContract', - 'PortalDelegationSettings', - 'PortalRevisionCollection', - 'PortalRevisionContract', - 'PortalSettingValidationKeyContract', - 'PortalSettingsCollection', - 'PortalSettingsContract', - 'PortalSigninSettings', - 'PortalSignupSettings', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateEndpointConnectionRequest', - 'PrivateEndpointConnectionRequestProperties', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProductCollection', - 'ProductContract', - 'ProductContractProperties', - 'ProductEntityBaseParameters', - 'ProductTagResourceContractProperties', - 'ProductUpdateParameters', - 'ProductUpdateProperties', - 'QuotaCounterCollection', - 'QuotaCounterContract', - 'QuotaCounterValueContract', - 'QuotaCounterValueContractProperties', - 'QuotaCounterValueUpdateContract', - 'RecipientEmailCollection', - 'RecipientEmailContract', - 'RecipientUserCollection', - 'RecipientUserContract', - 'RecipientsContractProperties', - 'RegionContract', - 'RegionListResult', - 'RegistrationDelegationSettingsProperties', - 'RemotePrivateEndpointConnectionWrapper', - 'ReportCollection', - 'ReportRecordContract', - 'RepresentationContract', - 'RequestContract', - 'RequestReportCollection', - 'RequestReportRecordContract', - 'Resource', - 'ResourceLocationDataContract', - 'ResourceSku', - 'ResourceSkuCapacity', - 'ResourceSkuResult', - 'ResourceSkuResults', - 'ResponseContract', - 'SamplingSettings', - 'SaveConfigurationParameter', - 'SchemaCollection', - 'SchemaContract', - 'SubscriptionCollection', - 'SubscriptionContract', - 'SubscriptionCreateParameters', - 'SubscriptionKeyParameterNamesContract', - 'SubscriptionKeysContract', - 'SubscriptionUpdateParameters', - 'SubscriptionsDelegationSettingsProperties', - 'SystemData', - 'TagCollection', - 'TagContract', - 'TagCreateUpdateParameters', - 'TagDescriptionBaseProperties', - 'TagDescriptionCollection', - 'TagDescriptionContract', - 'TagDescriptionContractProperties', - 'TagDescriptionCreateParameters', - 'TagResourceCollection', - 'TagResourceContract', - 'TagResourceContractProperties', - 'TenantConfigurationSyncStateContract', - 'TenantSettingsCollection', - 'TenantSettingsContract', - 'TermsOfServiceProperties', - 'TokenBodyParameterContract', - 'UserCollection', - 'UserContract', - 'UserContractProperties', - 'UserCreateParameterProperties', - 'UserCreateParameters', - 'UserEntityBaseParameters', - 'UserIdentityCollection', - 'UserIdentityContract', - 'UserIdentityProperties', - 'UserTokenParameters', - 'UserTokenResult', - 'UserUpdateParameters', - 'UserUpdateParametersProperties', - 'VirtualNetworkConfiguration', - 'X509CertificateName', - 'AccessIdName', - 'AccessType', - 'AlwaysLog', - 'ApiManagementSkuCapacityScaleType', - 'ApiManagementSkuRestrictionsReasonCode', - 'ApiManagementSkuRestrictionsType', - 'ApiType', - 'ApiVersionSetContractDetailsVersioningScheme', - 'ApimIdentityType', - 'AppType', - 'AsyncOperationStatus', - 'AuthorizationMethod', - 'BackendProtocol', - 'BearerTokenSendingMethod', - 'BearerTokenSendingMethods', - 'CertificateConfigurationStoreName', - 'CertificateSource', - 'CertificateStatus', - 'ClientAuthenticationMethod', - 'ConfigurationIdName', - 'Confirmation', - 'ConnectionStatus', - 'ConnectivityCheckProtocol', - 'ConnectivityStatusType', - 'ContentFormat', - 'CreatedByType', - 'DataMaskingMode', - 'ExportApi', - 'ExportFormat', - 'ExportResultFormat', - 'GrantType', - 'GroupType', - 'HostnameType', - 'HttpCorrelationProtocol', - 'IdentityProviderType', - 'IssueType', - 'KeyType', - 'LoggerType', - 'Method', - 'NameAvailabilityReason', - 'NotificationName', - 'OperationNameFormat', - 'Origin', - 'PlatformVersion', - 'PolicyContentFormat', - 'PolicyExportFormat', - 'PolicyIdName', - 'PolicyScopeContract', - 'PortalRevisionStatus', - 'PreferredIPVersion', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProductState', - 'Protocol', - 'PublicNetworkAccess', - 'ResourceSkuCapacityScaleType', - 'SamplingType', - 'SchemaType', - 'SettingsTypeName', - 'Severity', - 'SkuType', - 'SoapApiType', - 'State', - 'SubscriptionState', - 'TemplateName', - 'UserState', - 'Verbosity', - 'VersioningScheme', - 'VirtualNetworkType', + "AccessInformationCollection", + "AccessInformationContract", + "AccessInformationCreateParameters", + "AccessInformationSecretsContract", + "AccessInformationUpdateParameters", + "AdditionalLocation", + "ApiCollection", + "ApiContactInformation", + "ApiContract", + "ApiContractProperties", + "ApiContractUpdateProperties", + "ApiCreateOrUpdateParameter", + "ApiCreateOrUpdateProperties", + "ApiCreateOrUpdatePropertiesWsdlSelector", + "ApiEntityBaseContract", + "ApiExportResult", + "ApiExportResultValue", + "ApiLicenseInformation", + "ApiManagementServiceApplyNetworkConfigurationParameters", + "ApiManagementServiceBackupRestoreParameters", + "ApiManagementServiceBaseProperties", + "ApiManagementServiceCheckNameAvailabilityParameters", + "ApiManagementServiceGetDomainOwnershipIdentifierResult", + "ApiManagementServiceGetSsoTokenResult", + "ApiManagementServiceIdentity", + "ApiManagementServiceListResult", + "ApiManagementServiceNameAvailabilityResult", + "ApiManagementServiceProperties", + "ApiManagementServiceResource", + "ApiManagementServiceSkuProperties", + "ApiManagementServiceUpdateParameters", + "ApiManagementServiceUpdateProperties", + "ApiManagementSku", + "ApiManagementSkuCapabilities", + "ApiManagementSkuCapacity", + "ApiManagementSkuCosts", + "ApiManagementSkuLocationInfo", + "ApiManagementSkuRestrictionInfo", + "ApiManagementSkuRestrictions", + "ApiManagementSkuZoneDetails", + "ApiManagementSkusResult", + "ApiReleaseCollection", + "ApiReleaseContract", + "ApiRevisionCollection", + "ApiRevisionContract", + "ApiRevisionInfoContract", + "ApiTagResourceContractProperties", + "ApiUpdateContract", + "ApiVersionConstraint", + "ApiVersionSetCollection", + "ApiVersionSetContract", + "ApiVersionSetContractDetails", + "ApiVersionSetContractProperties", + "ApiVersionSetEntityBase", + "ApiVersionSetUpdateParameters", + "ApiVersionSetUpdateParametersProperties", + "ApimResource", + "ArmIdWrapper", + "AssociationContract", + "AuthenticationSettingsContract", + "AuthorizationServerCollection", + "AuthorizationServerContract", + "AuthorizationServerContractBaseProperties", + "AuthorizationServerContractProperties", + "AuthorizationServerSecretsContract", + "AuthorizationServerUpdateContract", + "AuthorizationServerUpdateContractProperties", + "BackendAuthorizationHeaderCredentials", + "BackendBaseParameters", + "BackendCollection", + "BackendContract", + "BackendContractProperties", + "BackendCredentialsContract", + "BackendProperties", + "BackendProxyContract", + "BackendReconnectContract", + "BackendServiceFabricClusterProperties", + "BackendTlsProperties", + "BackendUpdateParameterProperties", + "BackendUpdateParameters", + "BodyDiagnosticSettings", + "CacheCollection", + "CacheContract", + "CacheUpdateParameters", + "CertificateCollection", + "CertificateConfiguration", + "CertificateContract", + "CertificateCreateOrUpdateParameters", + "CertificateInformation", + "ClientSecretContract", + "ConnectivityCheckRequest", + "ConnectivityCheckRequestDestination", + "ConnectivityCheckRequestProtocolConfiguration", + "ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration", + "ConnectivityCheckRequestSource", + "ConnectivityCheckResponse", + "ConnectivityHop", + "ConnectivityIssue", + "ConnectivityStatusContract", + "ContentItemCollection", + "ContentItemContract", + "ContentTypeCollection", + "ContentTypeContract", + "DataMasking", + "DataMaskingEntity", + "DeletedServiceContract", + "DeletedServicesCollection", + "DeployConfigurationParameters", + "DiagnosticCollection", + "DiagnosticContract", + "EmailTemplateCollection", + "EmailTemplateContract", + "EmailTemplateParametersContractProperties", + "EmailTemplateUpdateParameters", + "EndpointDependency", + "EndpointDetail", + "ErrorFieldContract", + "ErrorResponse", + "ErrorResponseBody", + "GatewayCertificateAuthorityCollection", + "GatewayCertificateAuthorityContract", + "GatewayCollection", + "GatewayContract", + "GatewayHostnameConfigurationCollection", + "GatewayHostnameConfigurationContract", + "GatewayKeyRegenerationRequestContract", + "GatewayKeysContract", + "GatewayTokenContract", + "GatewayTokenRequestContract", + "GenerateSsoUrlResult", + "GlobalSchemaCollection", + "GlobalSchemaContract", + "GroupCollection", + "GroupContract", + "GroupContractProperties", + "GroupCreateParameters", + "GroupUpdateParameters", + "HTTPHeader", + "HostnameConfiguration", + "HttpMessageDiagnostic", + "IdentityProviderBaseParameters", + "IdentityProviderContract", + "IdentityProviderContractProperties", + "IdentityProviderCreateContract", + "IdentityProviderCreateContractProperties", + "IdentityProviderList", + "IdentityProviderUpdateParameters", + "IdentityProviderUpdateProperties", + "IssueAttachmentCollection", + "IssueAttachmentContract", + "IssueCollection", + "IssueCommentCollection", + "IssueCommentContract", + "IssueContract", + "IssueContractBaseProperties", + "IssueContractProperties", + "IssueUpdateContract", + "IssueUpdateContractProperties", + "KeyVaultContractCreateProperties", + "KeyVaultContractProperties", + "KeyVaultLastAccessStatusContractProperties", + "LoggerCollection", + "LoggerContract", + "LoggerUpdateContract", + "NamedValueCollection", + "NamedValueContract", + "NamedValueContractProperties", + "NamedValueCreateContract", + "NamedValueCreateContractProperties", + "NamedValueEntityBaseParameters", + "NamedValueSecretContract", + "NamedValueUpdateParameterProperties", + "NamedValueUpdateParameters", + "NetworkStatusContract", + "NetworkStatusContractByLocation", + "NotificationCollection", + "NotificationContract", + "OAuth2AuthenticationSettingsContract", + "OpenIdAuthenticationSettingsContract", + "OpenIdConnectProviderCollection", + "OpenidConnectProviderContract", + "OpenidConnectProviderUpdateContract", + "Operation", + "OperationCollection", + "OperationContract", + "OperationContractProperties", + "OperationDisplay", + "OperationEntityBaseContract", + "OperationListResult", + "OperationResultContract", + "OperationResultLogItemContract", + "OperationTagResourceContractProperties", + "OperationUpdateContract", + "OperationUpdateContractProperties", + "OutboundEnvironmentEndpoint", + "OutboundEnvironmentEndpointList", + "ParameterContract", + "ParameterExampleContract", + "PipelineDiagnosticSettings", + "PolicyCollection", + "PolicyContract", + "PolicyDescriptionCollection", + "PolicyDescriptionContract", + "PortalDelegationSettings", + "PortalRevisionCollection", + "PortalRevisionContract", + "PortalSettingValidationKeyContract", + "PortalSettingsCollection", + "PortalSettingsContract", + "PortalSigninSettings", + "PortalSignupSettings", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateEndpointConnectionRequest", + "PrivateEndpointConnectionRequestProperties", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProductCollection", + "ProductContract", + "ProductContractProperties", + "ProductEntityBaseParameters", + "ProductTagResourceContractProperties", + "ProductUpdateParameters", + "ProductUpdateProperties", + "QuotaCounterCollection", + "QuotaCounterContract", + "QuotaCounterValueContract", + "QuotaCounterValueContractProperties", + "QuotaCounterValueUpdateContract", + "RecipientEmailCollection", + "RecipientEmailContract", + "RecipientUserCollection", + "RecipientUserContract", + "RecipientsContractProperties", + "RegionContract", + "RegionListResult", + "RegistrationDelegationSettingsProperties", + "RemotePrivateEndpointConnectionWrapper", + "ReportCollection", + "ReportRecordContract", + "RepresentationContract", + "RequestContract", + "RequestReportCollection", + "RequestReportRecordContract", + "Resource", + "ResourceLocationDataContract", + "ResourceSku", + "ResourceSkuCapacity", + "ResourceSkuResult", + "ResourceSkuResults", + "ResponseContract", + "SamplingSettings", + "SaveConfigurationParameter", + "SchemaCollection", + "SchemaContract", + "SubscriptionCollection", + "SubscriptionContract", + "SubscriptionCreateParameters", + "SubscriptionKeyParameterNamesContract", + "SubscriptionKeysContract", + "SubscriptionUpdateParameters", + "SubscriptionsDelegationSettingsProperties", + "SystemData", + "TagCollection", + "TagContract", + "TagCreateUpdateParameters", + "TagDescriptionBaseProperties", + "TagDescriptionCollection", + "TagDescriptionContract", + "TagDescriptionContractProperties", + "TagDescriptionCreateParameters", + "TagResourceCollection", + "TagResourceContract", + "TagResourceContractProperties", + "TenantConfigurationSyncStateContract", + "TenantSettingsCollection", + "TenantSettingsContract", + "TermsOfServiceProperties", + "TokenBodyParameterContract", + "UserCollection", + "UserContract", + "UserContractProperties", + "UserCreateParameterProperties", + "UserCreateParameters", + "UserEntityBaseParameters", + "UserIdentityCollection", + "UserIdentityContract", + "UserIdentityProperties", + "UserTokenParameters", + "UserTokenResult", + "UserUpdateParameters", + "UserUpdateParametersProperties", + "VirtualNetworkConfiguration", + "X509CertificateName", + "AccessIdName", + "AccessType", + "AlwaysLog", + "ApiManagementSkuCapacityScaleType", + "ApiManagementSkuRestrictionsReasonCode", + "ApiManagementSkuRestrictionsType", + "ApiType", + "ApiVersionSetContractDetailsVersioningScheme", + "ApimIdentityType", + "AppType", + "AsyncOperationStatus", + "AuthorizationMethod", + "BackendProtocol", + "BearerTokenSendingMethod", + "BearerTokenSendingMethods", + "CertificateConfigurationStoreName", + "CertificateSource", + "CertificateStatus", + "ClientAuthenticationMethod", + "ConfigurationIdName", + "Confirmation", + "ConnectionStatus", + "ConnectivityCheckProtocol", + "ConnectivityStatusType", + "ContentFormat", + "CreatedByType", + "DataMaskingMode", + "ExportApi", + "ExportFormat", + "ExportResultFormat", + "GrantType", + "GroupType", + "HostnameType", + "HttpCorrelationProtocol", + "IdentityProviderType", + "IssueType", + "KeyType", + "LoggerType", + "Method", + "NameAvailabilityReason", + "NotificationName", + "OperationNameFormat", + "Origin", + "PlatformVersion", + "PolicyContentFormat", + "PolicyExportFormat", + "PolicyIdName", + "PolicyScopeContract", + "PortalRevisionStatus", + "PreferredIPVersion", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProductState", + "Protocol", + "PublicNetworkAccess", + "ResourceSkuCapacityScaleType", + "SamplingType", + "SchemaType", + "SettingsTypeName", + "Severity", + "SkuType", + "SoapApiType", + "State", + "SubscriptionState", + "TemplateName", + "UserState", + "Verbosity", + "VersioningScheme", + "VirtualNetworkType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py index b194dd14e5180..2e8ec9b684f4e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py @@ -7,18 +7,18 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessIdName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessIdName.""" ACCESS = "access" GIT_ACCESS = "gitAccess" -class AccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of access to be used for the storage account. - """ + +class AccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of access to be used for the storage account.""" #: Use access key. ACCESS_KEY = "AccessKey" @@ -27,36 +27,37 @@ class AccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Use user assigned managed identity. USER_ASSIGNED_MANAGED_IDENTITY = "UserAssignedManagedIdentity" -class AlwaysLog(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specifies for what type of messages sampling settings should not apply. - """ + +class AlwaysLog(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies for what type of messages sampling settings should not apply.""" #: Always log all erroneous request regardless of sampling settings. ALL_ERRORS = "allErrors" -class ApiManagementSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The scale type applicable to the sku. - """ + +class ApiManagementSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scale type applicable to the sku.""" AUTOMATIC = "Automatic" MANUAL = "Manual" NONE = "None" -class ApiManagementSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason for restriction. - """ + +class ApiManagementSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for restriction.""" QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ApiManagementSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of restrictions. - """ + +class ApiManagementSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of restrictions.""" LOCATION = "Location" ZONE = "Zone" -class ApimIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ApimIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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. @@ -67,40 +68,44 @@ class ApimIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class ApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of API. - """ + +class ApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of API.""" HTTP = "http" SOAP = "soap" WEBSOCKET = "websocket" GRAPHQL = "graphql" -class ApiVersionSetContractDetailsVersioningScheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """An value that determines where the API Version identifier will be located in a HTTP request. - """ + +class ApiVersionSetContractDetailsVersioningScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An value that determines where the API Version identifier will be located in a HTTP request.""" SEGMENT = "Segment" QUERY = "Query" HEADER = "Header" -class AppType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class AppType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AppType.""" #: User create request was sent by legacy developer portal. PORTAL = "portal" #: User create request was sent by new developer portal. DEVELOPER_PORTAL = "developerPortal" -class AsyncOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of an async operation. - """ + +class AsyncOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of an async operation.""" STARTED = "Started" IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" -class AuthorizationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class AuthorizationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AuthorizationMethod.""" HEAD = "HEAD" OPTIONS = "OPTIONS" @@ -111,30 +116,33 @@ class AuthorizationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PATCH = "PATCH" DELETE = "DELETE" -class BackendProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Backend communication protocol. - """ + +class BackendProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Backend communication protocol.""" #: The Backend is a RESTful service. HTTP = "http" #: The Backend is a SOAP service. SOAP = "soap" -class BearerTokenSendingMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class BearerTokenSendingMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BearerTokenSendingMethod.""" AUTHORIZATION_HEADER = "authorizationHeader" QUERY = "query" -class BearerTokenSendingMethods(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Form of an authorization grant, which the client uses to request the access token. - """ - #: Access token will be transmitted in the Authorization header using Bearer schema. +class BearerTokenSendingMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Form of an authorization grant, which the client uses to request the access token.""" + + #: Access token will be transmitted in the Authorization header using Bearer schema AUTHORIZATION_HEADER = "authorizationHeader" #: Access token will be transmitted as query parameters. QUERY = "query" -class CertificateConfigurationStoreName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class CertificateConfigurationStoreName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority are valid locations. """ @@ -142,53 +150,58 @@ class CertificateConfigurationStoreName(with_metaclass(CaseInsensitiveEnumMeta, CERTIFICATE_AUTHORITY = "CertificateAuthority" ROOT = "Root" -class CertificateSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Certificate Source. - """ + +class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Certificate Source.""" MANAGED = "Managed" KEY_VAULT = "KeyVault" CUSTOM = "Custom" BUILT_IN = "BuiltIn" -class CertificateStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Certificate Status. - """ + +class CertificateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Certificate Status.""" COMPLETED = "Completed" FAILED = "Failed" IN_PROGRESS = "InProgress" -class ClientAuthenticationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ClientAuthenticationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ClientAuthenticationMethod.""" #: Basic Client Authentication method. BASIC = "Basic" #: Body based Authentication method. BODY = "Body" -class ConfigurationIdName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ConfigurationIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ConfigurationIdName.""" CONFIGURATION = "configuration" -class Confirmation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Determines the type of confirmation e-mail that will be sent to the newly created user. - """ + +class Confirmation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Determines the type of confirmation e-mail that will be sent to the newly created user.""" #: Send an e-mail to the user confirming they have successfully signed up. SIGNUP = "signup" #: Send an e-mail inviting the user to sign-up and complete registration. INVITE = "invite" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The connection status.""" UNKNOWN = "Unknown" CONNECTED = "Connected" DISCONNECTED = "Disconnected" DEGRADED = "Degraded" -class ConnectivityCheckProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ConnectivityCheckProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The request's protocol. Specific protocol configuration can be available based on this selection. The specified destination address must be coherent with this value. """ @@ -197,17 +210,17 @@ class ConnectivityCheckProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enu HTTP = "HTTP" HTTPS = "HTTPS" -class ConnectivityStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Resource Connectivity Status Type identifier. - """ + +class ConnectivityStatusType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Resource Connectivity Status Type identifier.""" INITIALIZING = "initializing" SUCCESS = "success" FAILURE = "failure" -class ContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Format of the Content in which the API is getting imported. - """ + +class ContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Format of the Content in which the API is getting imported.""" #: The contents are inline and Content type is a WADL document. WADL_XML = "wadl-xml" @@ -232,34 +245,38 @@ class ContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The GraphQL API endpoint hosted on a publicly accessible internet address. GRAPHQL_LINK = "graphql-link" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataMaskingMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Data masking mode. - """ + +class DataMaskingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data masking mode.""" #: Mask the value of an entity. MASK = "Mask" #: Hide the presence of an entity. HIDE = "Hide" -class ExportApi(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExportApi(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExportApi.""" TRUE = "true" -class ExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExportFormat.""" #: Export the Api Definition in OpenAPI 2.0 Specification as JSON document to the Storage Blob. SWAGGER = "swagger-link" #: Export the Api Definition in WSDL Schema to Storage Blob. This is only supported for APIs of - #: Type ``soap``. + #: Type ``soap`` WSDL = "wsdl-link" #: Export the Api Definition in WADL Schema to Storage Blob. WADL = "wadl-link" @@ -268,7 +285,8 @@ class ExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Export the Api Definition in OpenAPI 3.0 Specification as JSON document to Storage Blob. OPENAPI_JSON = "openapi+json-link" -class ExportResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExportResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Format in which the API Details are exported to the Storage Blob with Sas Key valid for 5 minutes. """ @@ -276,14 +294,16 @@ class ExportResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The API Definition is exported in OpenAPI Specification 2.0 format to the Storage Blob. SWAGGER = "swagger-link-json" #: The API Definition is exported in WSDL Schema to Storage Blob. This is only supported for APIs - #: of Type ``soap``. + #: of Type ``soap`` WSDL = "wsdl-link+xml" #: Export the API Definition in WADL Schema to Storage Blob. WADL = "wadl-link-json" #: Export the API Definition in OpenAPI Specification 3.0 to Storage Blob. OPEN_API = "openapi-link" -class GrantType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class GrantType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """GrantType.""" #: Authorization Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.1. AUTHORIZATION_CODE = "authorizationCode" @@ -295,17 +315,17 @@ class GrantType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Client Credentials Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.4. CLIENT_CREDENTIALS = "clientCredentials" -class GroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Group type. - """ + +class GroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Group type.""" CUSTOM = "custom" SYSTEM = "system" EXTERNAL = "external" -class HostnameType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Hostname type. - """ + +class HostnameType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Hostname type.""" PROXY = "Proxy" PORTAL = "Portal" @@ -313,9 +333,9 @@ class HostnameType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SCM = "Scm" DEVELOPER_PORTAL = "DeveloperPortal" -class HttpCorrelationProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Sets correlation protocol to use for Application Insights diagnostics. - """ + +class HttpCorrelationProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sets correlation protocol to use for Application Insights diagnostics.""" #: Do not read and inject correlation headers. NONE = "None" @@ -325,7 +345,9 @@ class HttpCorrelationProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: Inject Trace Context headers. See https://w3c.github.io/trace-context. W3_C = "W3C" -class IdentityProviderType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IdentityProviderType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IdentityProviderType.""" #: Facebook as Identity provider. FACEBOOK = "facebook" @@ -340,9 +362,9 @@ class IdentityProviderType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Azure Active Directory B2C as Identity provider. AAD_B2_C = "aadB2C" -class IssueType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of issue. - """ + +class IssueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of issue.""" UNKNOWN = "Unknown" AGENT_STOPPED = "AgentStopped" @@ -354,32 +376,33 @@ class IssueType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PORT_THROTTLED = "PortThrottled" PLATFORM = "Platform" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The Key to be used to generate token for user. - """ + +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Key to be used to generate token for user.""" PRIMARY = "primary" SECONDARY = "secondary" -class LoggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Logger type. - """ + +class LoggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Logger type.""" #: Azure Event Hub as log destination. AZURE_EVENT_HUB = "azureEventHub" #: Azure Application Insights as log destination. APPLICATION_INSIGHTS = "applicationInsights" - #: Azure Monitor. + #: Azure Monitor AZURE_MONITOR = "azureMonitor" -class Method(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The HTTP method to be used. - """ + +class Method(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The HTTP method to be used.""" GET = "GET" POST = "POST" -class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class NameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invalid indicates the name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. @@ -389,7 +412,9 @@ class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class NotificationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class NotificationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """NotificationName.""" #: The following email recipients and users will receive email notifications about subscription #: requests for API products requiring approval. @@ -412,26 +437,26 @@ class NotificationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: usage gets close to usage quota. QUOTA_LIMIT_APPROACHING_PUBLISHER_NOTIFICATION_MESSAGE = "QuotaLimitApproachingPublisherNotificationMessage" -class OperationNameFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the Operation Name for Application Insights telemetries. Default is Name. - """ - #: API_NAME;rev=API_REVISION - OPERATION_NAME. +class OperationNameFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the Operation Name for Application Insights telemetries. Default is Name.""" + + #: API_NAME;rev=API_REVISION - OPERATION_NAME NAME = "Name" - #: HTTP_VERB URL. + #: HTTP_VERB URL URL = "Url" -class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The origin of the issue. - """ + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The origin of the issue.""" LOCAL = "Local" INBOUND = "Inbound" OUTBOUND = "Outbound" -class PlatformVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Compute Platform Version running the service. - """ + +class PlatformVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compute Platform Version running the service.""" #: Platform version cannot be determined, as compute platform is not deployed. UNDETERMINED = "undetermined" @@ -442,9 +467,9 @@ class PlatformVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Platform running the service on Multi Tenant V1 platform. MTV1 = "mtv1" -class PolicyContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Format of the policyContent. - """ + +class PolicyContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Format of the policyContent.""" #: The contents are inline and Content type is an XML document. XML = "xml" @@ -457,18 +482,24 @@ class PolicyContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Management service. RAWXML_LINK = "rawxml-link" -class PolicyExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PolicyExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PolicyExportFormat.""" #: The contents are inline and Content type is an XML document. XML = "xml" #: The contents are inline and Content type is a non XML encoded policy document. RAWXML = "rawxml" -class PolicyIdName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PolicyIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PolicyIdName.""" POLICY = "policy" -class PolicyScopeContract(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PolicyScopeContract(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PolicyScopeContract.""" TENANT = "Tenant" PRODUCT = "Product" @@ -476,9 +507,9 @@ class PolicyScopeContract(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): OPERATION = "Operation" ALL = "All" -class PortalRevisionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the portal's revision. - """ + +class PortalRevisionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the portal's revision.""" #: Portal's revision has been queued. PENDING = "pending" @@ -489,30 +520,31 @@ class PortalRevisionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Portal's revision publishing failed. FAILED = "failed" -class PreferredIPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The IP version to be used. Only IPv4 is supported for now. - """ + +class PreferredIPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The IP version to be used. Only IPv4 is supported for now.""" I_PV4 = "IPv4" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current provisioning state. - """ + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private endpoint connection status. - """ + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" -class ProductState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ProductState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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. @@ -521,25 +553,28 @@ class ProductState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NOT_PUBLISHED = "notPublished" PUBLISHED = "published" -class Protocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Protocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Protocol.""" HTTP = "http" HTTPS = "https" WS = "ws" WSS = "wss" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints - are the exclusive access method. Default value is 'Enabled' + are the exclusive access method. Default value is 'Enabled'. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The scale type applicable to the sku. - """ + +class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scale type applicable to the sku.""" #: Supported scale type automatic. AUTOMATIC = "automatic" @@ -548,36 +583,38 @@ class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, #: Scaling not supported. NONE = "none" -class SamplingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Sampling type. - """ + +class SamplingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sampling type.""" #: Fixed-rate sampling. FIXED = "fixed" -class SchemaType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Schema Type. Immutable. - """ + +class SchemaType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Schema Type. Immutable.""" #: Xml schema type. XML = "xml" #: Json schema type. JSON = "json" -class SettingsTypeName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SettingsTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SettingsTypeName.""" PUBLIC = "public" -class Severity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The severity of the issue. - """ + +class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The severity of the issue.""" ERROR = "Error" WARNING = "Warning" -class SkuType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Name of the Sku. - """ + +class SkuType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of the Sku.""" #: Developer SKU of Api Management. DEVELOPER = "Developer" @@ -592,10 +629,11 @@ class SkuType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Isolated SKU of Api Management. ISOLATED = "Isolated" -class SoapApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +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 @@ -611,9 +649,9 @@ class SoapApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Imports the API having a GraphQL front end. GRAPH_QL = "graphql" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the issue. - """ + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the issue.""" #: The issue is proposed. PROPOSED = "proposed" @@ -626,7 +664,8 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The issue was closed. CLOSED = "closed" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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 @@ -642,7 +681,9 @@ class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REJECTED = "rejected" CANCELLED = "cancelled" -class TemplateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TemplateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TemplateName.""" APPLICATION_APPROVED_NOTIFICATION_MESSAGE = "applicationApprovedNotificationMessage" ACCOUNT_CLOSED_DEVELOPER = "accountClosedDeveloper" @@ -659,7 +700,8 @@ class TemplateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REJECT_DEVELOPER_NOTIFICATION_MESSAGE = "rejectDeveloperNotificationMessage" REQUEST_DEVELOPER_NOTIFICATION_MESSAGE = "requestDeveloperNotificationMessage" -class UserState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class UserState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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. """ @@ -673,9 +715,9 @@ class UserState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: User account is closed. All identities and related entities are removed. DELETED = "deleted" -class Verbosity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The verbosity level applied to traces emitted by trace policies. - """ + +class Verbosity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The verbosity level applied to traces emitted by trace policies.""" #: All the traces emitted by trace policies will be sent to the logger attached to this diagnostic #: instance. @@ -687,9 +729,9 @@ class Verbosity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: diagnostic instance. ERROR = "error" -class VersioningScheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """An value that determines where the API Version identifier will be located in a HTTP request. - """ + +class VersioningScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An value that determines where the API Version identifier will be located in a HTTP request.""" #: The API Version is passed in a path segment. SEGMENT = "Segment" @@ -698,7 +740,8 @@ class VersioningScheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The API Version is passed in a HTTP header. HEADER = "Header" -class VirtualNetworkType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class VirtualNetworkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py index 37a29aafe06de..ad1159ae09baa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,55 +8,57 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._api_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccessInformationCollection(msrest.serialization.Model): +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[~api_management_client.models.AccessInformationContract] + :vartype value: list[~azure.mgmt.apimanagement.models.AccessInformationContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessInformationContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AccessInformationContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(AccessInformationCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None -class Resource(msrest.serialization.Model): +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. @@ -71,24 +74,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -116,18 +115,18 @@ class AccessInformationContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -146,13 +145,13 @@ def __init__( :keyword enabled: Determines whether direct access is enabled. :paramtype enabled: bool """ - super(AccessInformationContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.id_properties_id = id_properties_id self.principal_id = principal_id self.enabled = enabled -class AccessInformationCreateParameters(msrest.serialization.Model): +class AccessInformationCreateParameters(_serialization.Model): """Tenant access information update parameters. :ivar principal_id: Principal (User) Identifier. @@ -168,10 +167,10 @@ class AccessInformationCreateParameters(msrest.serialization.Model): """ _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'}, + "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__( @@ -195,14 +194,14 @@ def __init__( :keyword enabled: Determines whether direct access is enabled. :paramtype enabled: bool """ - super(AccessInformationCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.primary_key = primary_key self.secondary_key = secondary_key self.enabled = enabled -class AccessInformationSecretsContract(msrest.serialization.Model): +class AccessInformationSecretsContract(_serialization.Model): """Tenant access information contract of the API Management service. :ivar id: Access Information type ('access' or 'gitAccess'). @@ -220,17 +219,17 @@ class AccessInformationSecretsContract(msrest.serialization.Model): """ _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'}, + "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, + id: Optional[str] = None, # pylint: disable=redefined-builtin principal_id: Optional[str] = None, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, @@ -251,7 +250,7 @@ def __init__( :keyword enabled: Determines whether direct access is enabled. :paramtype enabled: bool """ - super(AccessInformationSecretsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.principal_id = principal_id self.primary_key = primary_key @@ -259,7 +258,7 @@ def __init__( self.enabled = enabled -class AccessInformationUpdateParameters(msrest.serialization.Model): +class AccessInformationUpdateParameters(_serialization.Model): """Tenant access information update parameters. :ivar enabled: Determines whether direct access is enabled. @@ -267,35 +266,30 @@ class AccessInformationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Determines whether direct access is enabled. :paramtype enabled: bool """ - super(AccessInformationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class AdditionalLocation(msrest.serialization.Model): +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 Azure. - :ivar location: Required. The location name of the additional region among Azure Data center - regions. + :ivar location: The location name of the additional region among Azure Data center regions. + Required. :vartype location: str - :ivar sku: Required. SKU properties of the API Management service. - :vartype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :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 @@ -312,56 +306,56 @@ class AdditionalLocation(msrest.serialization.Model): :vartype public_ip_address_id: str :ivar virtual_network_configuration: Virtual network configuration for the location. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~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 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. Possible values include: - "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + :ivar platform_version: Compute Platform Version running the service. Known values are: + "undetermined", "stv1", "stv2", and "mtv1". + :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}, - 'platform_version': {'readonly': True}, + "location": {"required": True}, + "sku": {"required": True}, + "public_ip_addresses": {"readonly": True}, + "private_ip_addresses": {"readonly": True}, + "gateway_regional_url": {"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'}, - 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, - 'platform_version': {'key': 'platformVersion', 'type': 'str'}, + "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"}, + "disable_gateway": {"key": "disableGateway", "type": "bool"}, + "platform_version": {"key": "platformVersion", "type": "str"}, } def __init__( self, *, location: str, - sku: "ApiManagementServiceSkuProperties", + sku: "_models.ApiManagementServiceSkuProperties", zones: Optional[List[str]] = None, public_ip_address_id: Optional[str] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - disable_gateway: Optional[bool] = False, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + disable_gateway: bool = False, **kwargs ): """ - :keyword location: Required. The location name of the additional region among Azure Data center - regions. + :keyword location: The location name of the additional region among Azure Data center regions. + Required. :paramtype location: str - :keyword sku: Required. SKU properties of the API Management service. - :paramtype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :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 @@ -370,12 +364,12 @@ def __init__( :paramtype public_ip_address_id: str :keyword virtual_network_configuration: Virtual network configuration for the location. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :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(AdditionalLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.sku = sku self.zones = zones @@ -388,47 +382,42 @@ def __init__( self.platform_version = None -class ApiCollection(msrest.serialization.Model): +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[~api_management_client.models.ApiContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(ApiCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None -class ApiContactInformation(msrest.serialization.Model): +class ApiContactInformation(_serialization.Model): """API contact information. :ivar name: The identifying name of the contact person/organization. @@ -441,19 +430,12 @@ class ApiContactInformation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, + "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 - ): + def __init__(self, *, name: Optional[str] = None, url: Optional[str] = None, email: Optional[str] = None, **kwargs): """ :keyword name: The identifying name of the contact person/organization. :paramtype name: str @@ -463,13 +445,13 @@ def __init__( an email address. :paramtype email: str """ - super(ApiContactInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.url = url self.email = email -class ApiContract(Resource): +class ApiContract(Resource): # pylint: disable=too-many-instance-attributes """API details. Variables are only populated by the server, and will be ignored when sending a request. @@ -485,12 +467,13 @@ class ApiContract(Resource): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -513,9 +496,9 @@ class ApiContract(Resource): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -528,59 +511,65 @@ class ApiContract(Resource): 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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'max_length': 400, 'min_length': 0}, - } - - _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'}, - } - - def __init__( + "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}, + } + + _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"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -589,14 +578,14 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = 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, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, **kwargs ): """ @@ -604,13 +593,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -631,9 +619,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -646,11 +634,11 @@ def __init__( 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 ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ - super(ApiContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings self.subscription_key_parameter_names = subscription_key_parameter_names @@ -674,7 +662,7 @@ def __init__( self.api_version_set = api_version_set -class ApiEntityBaseContract(msrest.serialization.Model): +class ApiEntityBaseContract(_serialization.Model): # pylint: disable=too-many-instance-attributes """API base contract details. Variables are only populated by the server, and will be ignored when sending a request. @@ -682,12 +670,13 @@ class ApiEntityBaseContract(msrest.serialization.Model): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -710,44 +699,47 @@ class ApiEntityBaseContract(msrest.serialization.Model): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation """ _validation = { - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - } - - _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'}, + "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["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -756,8 +748,8 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, **kwargs ): """ @@ -765,13 +757,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -792,11 +783,11 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation """ - super(ApiEntityBaseContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings self.subscription_key_parameter_names = subscription_key_parameter_names @@ -814,7 +805,7 @@ def __init__( self.license = license -class ApiContractProperties(ApiEntityBaseContract): +class ApiContractProperties(ApiEntityBaseContract): # pylint: disable=too-many-instance-attributes """API Entity Properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -824,12 +815,13 @@ class ApiContractProperties(ApiEntityBaseContract): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -852,9 +844,9 @@ class ApiContractProperties(ApiEntityBaseContract): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -862,49 +854,52 @@ class ApiContractProperties(ApiEntityBaseContract): :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: Required. 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. + :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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'required': True, 'max_length': 400, 'min_length': 0}, - } - - _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'}, + "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}, + } + + _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"}, } def __init__( @@ -912,9 +907,9 @@ def __init__( *, path: str, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -923,13 +918,13 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = 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, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, **kwargs ): """ @@ -937,13 +932,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -964,9 +958,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -974,16 +968,32 @@ def __init__( :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: Required. 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. + :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 ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails - """ - super(ApiContractProperties, self).__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) + :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 @@ -992,7 +1002,7 @@ def __init__( self.api_version_set = api_version_set -class ApiContractUpdateProperties(ApiEntityBaseContract): +class ApiContractUpdateProperties(ApiEntityBaseContract): # pylint: disable=too-many-instance-attributes """API update contract properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1000,12 +1010,13 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -1028,9 +1039,9 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -1040,49 +1051,52 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): 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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'service_url': {'max_length': 2000, 'min_length': 1}, - 'path': {'max_length': 400, 'min_length': 0}, - } - - _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]'}, + "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["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -1091,12 +1105,12 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = 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, "Protocol"]]] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, **kwargs ): """ @@ -1104,13 +1118,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -1131,9 +1144,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -1143,16 +1156,32 @@ def __init__( 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 ~api_management_client.models.Protocol] - """ - super(ApiContractUpdateProperties, self).__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) + :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(msrest.serialization.Model): +class ApiCreateOrUpdateParameter(_serialization.Model): # pylint: disable=too-many-instance-attributes """API Create or Update Parameters. Variables are only populated by the server, and will be ignored when sending a request. @@ -1160,12 +1189,13 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -1188,9 +1218,9 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -1203,74 +1233,81 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): 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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :ivar value: Content value when Importing an API. :vartype value: str - :ivar format: Format of the Content in which the API is getting imported. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :vartype format: str or ~api_management_client.models.ContentFormat + :ivar format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :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: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :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. Possible values include: "http", "soap", "websocket", + * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and "graphql". - :vartype soap_api_type: str or ~api_management_client.models.SoapApiType + :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'max_length': 400, 'min_length': 0}, - } - - _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'}, - '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'}, - } - - def __init__( + "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}, + } + + _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"}, + "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"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -1279,18 +1316,18 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = 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, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, value: Optional[str] = None, - format: Optional[Union[str, "ContentFormat"]] = None, - wsdl_selector: Optional["ApiCreateOrUpdatePropertiesWsdlSelector"] = None, - soap_api_type: Optional[Union[str, "SoapApiType"]] = None, + format: Optional[Union[str, "_models.ContentFormat"]] = None, + wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = None, + soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = None, **kwargs ): """ @@ -1298,13 +1335,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -1325,9 +1361,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -1340,28 +1376,29 @@ def __init__( 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 ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :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. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :paramtype format: str or ~api_management_client.models.ContentFormat + :keyword format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :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: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :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. Possible values include: "http", "soap", "websocket", + * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and "graphql". - :paramtype soap_api_type: str or ~api_management_client.models.SoapApiType + :paramtype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ - super(ApiCreateOrUpdateParameter, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings self.subscription_key_parameter_names = subscription_key_parameter_names @@ -1389,7 +1426,7 @@ def __init__( self.soap_api_type = soap_api_type -class ApiCreateOrUpdateProperties(ApiContractProperties): +class ApiCreateOrUpdateProperties(ApiContractProperties): # pylint: disable=too-many-instance-attributes """API Create or Update Properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1399,12 +1436,13 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -1427,9 +1465,9 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -1437,80 +1475,84 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): :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: Required. 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. + :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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :ivar value: Content value when Importing an API. :vartype value: str - :ivar format: Format of the Content in which the API is getting imported. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :vartype format: str or ~api_management_client.models.ContentFormat + :ivar format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :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: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :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. Possible values include: "http", "soap", "websocket", + * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and "graphql". - :vartype soap_api_type: str or ~api_management_client.models.SoapApiType + :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'required': True, 'max_length': 400, 'min_length': 0}, - } - - _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'}, - 'value': {'key': 'value', 'type': 'str'}, - 'format': {'key': 'format', 'type': 'str'}, - 'wsdl_selector': {'key': 'wsdlSelector', 'type': 'ApiCreateOrUpdatePropertiesWsdlSelector'}, - 'soap_api_type': {'key': 'apiType', 'type': 'str'}, - } - - def __init__( + "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}, + } + + _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"}, + "value": {"key": "value", "type": "str"}, + "format": {"key": "format", "type": "str"}, + "wsdl_selector": {"key": "wsdlSelector", "type": "ApiCreateOrUpdatePropertiesWsdlSelector"}, + "soap_api_type": {"key": "apiType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, path: str, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -1519,17 +1561,17 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = 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, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, value: Optional[str] = None, - format: Optional[Union[str, "ContentFormat"]] = None, - wsdl_selector: Optional["ApiCreateOrUpdatePropertiesWsdlSelector"] = None, - soap_api_type: Optional[Union[str, "SoapApiType"]] = None, + format: Optional[Union[str, "_models.ContentFormat"]] = None, + wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = None, + soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = None, **kwargs ): """ @@ -1537,13 +1579,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -1564,9 +1605,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -1574,40 +1615,63 @@ def __init__( :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: Required. 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. + :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 ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :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. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :paramtype format: str or ~api_management_client.models.ContentFormat + :keyword format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :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: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :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. Possible values include: "http", "soap", "websocket", + * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and "graphql". - :paramtype soap_api_type: str or ~api_management_client.models.SoapApiType - """ - super(ApiCreateOrUpdateProperties, self).__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) + :paramtype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType + """ + 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 -class ApiCreateOrUpdatePropertiesWsdlSelector(msrest.serialization.Model): +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. @@ -1617,72 +1681,66 @@ class ApiCreateOrUpdatePropertiesWsdlSelector(msrest.serialization.Model): """ _attribute_map = { - 'wsdl_service_name': {'key': 'wsdlServiceName', 'type': 'str'}, - 'wsdl_endpoint_name': {'key': 'wsdlEndpointName', 'type': 'str'}, + "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 - ): + def __init__(self, *, wsdl_service_name: Optional[str] = None, wsdl_endpoint_name: Optional[str] = None, **kwargs): """ :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(ApiCreateOrUpdatePropertiesWsdlSelector, self).__init__(**kwargs) + super().__init__(**kwargs) self.wsdl_service_name = wsdl_service_name self.wsdl_endpoint_name = wsdl_endpoint_name -class ApiExportResult(msrest.serialization.Model): +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. Possible values include: "swagger-link-json", - "wsdl-link+xml", "wadl-link-json", "openapi-link". - :vartype export_result_format: str or ~api_management_client.models.ExportResultFormat + 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: ~api_management_client.models.ApiExportResultValue + :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'}, + "id": {"key": "id", "type": "str"}, + "export_result_format": {"key": "format", "type": "str"}, + "value": {"key": "value", "type": "ApiExportResultValue"}, } def __init__( self, *, - id: Optional[str] = None, - export_result_format: Optional[Union[str, "ExportResultFormat"]] = None, - value: Optional["ApiExportResultValue"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + export_result_format: Optional[Union[str, "_models.ExportResultFormat"]] = None, + value: Optional["_models.ApiExportResultValue"] = None, **kwargs ): """ :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. Possible values include: "swagger-link-json", - "wsdl-link+xml", "wadl-link-json", "openapi-link". - :paramtype export_result_format: str or ~api_management_client.models.ExportResultFormat + 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: ~api_management_client.models.ApiExportResultValue + :paramtype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue """ - super(ApiExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.export_result_format = export_result_format self.value = value -class ApiExportResultValue(msrest.serialization.Model): +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 @@ -1691,25 +1749,20 @@ class ApiExportResultValue(msrest.serialization.Model): """ _attribute_map = { - 'link': {'key': 'link', 'type': 'str'}, + "link": {"key": "link", "type": "str"}, } - def __init__( - self, - *, - link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, link: Optional[str] = None, **kwargs): """ :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(ApiExportResultValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.link = link -class ApiLicenseInformation(msrest.serialization.Model): +class ApiLicenseInformation(_serialization.Model): """API license information. :ivar name: The license name used for the API. @@ -1719,29 +1772,23 @@ class ApiLicenseInformation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, url: Optional[str] = None, **kwargs): """ :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(ApiLicenseInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.url = url -class ApiManagementServiceApplyNetworkConfigurationParameters(msrest.serialization.Model): +class ApiManagementServiceApplyNetworkConfigurationParameters(_serialization.Model): """Parameter supplied to the Apply Network configuration operation. :ivar location: Location of the Api Management service to update for a multi-region service. @@ -1750,41 +1797,35 @@ class ApiManagementServiceApplyNetworkConfigurationParameters(msrest.serializati """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :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(ApiManagementServiceApplyNetworkConfigurationParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location -class ApiManagementServiceBackupRestoreParameters(msrest.serialization.Model): +class ApiManagementServiceBackupRestoreParameters(_serialization.Model): """Parameters supplied to the Backup/Restore of an API Management service operation. All required parameters must be populated in order to send to Azure. - :ivar storage_account: Required. The name of the Azure storage account (used to place/retrieve - the backup). + :ivar storage_account: The name of the Azure storage account (used to place/retrieve the + backup). Required. :vartype storage_account: str - :ivar container_name: Required. The name of the blob container (used to place/retrieve the - backup). + :ivar container_name: The name of the blob container (used to place/retrieve the backup). + Required. :vartype container_name: str - :ivar backup_name: Required. The name of the backup file to create/retrieve. + :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. Possible values - include: "AccessKey", "SystemAssignedManagedIdentity", "UserAssignedManagedIdentity". Default - value: "AccessKey". - :vartype access_type: str or ~api_management_client.models.AccessType + :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 @@ -1794,18 +1835,18 @@ class ApiManagementServiceBackupRestoreParameters(msrest.serialization.Model): """ _validation = { - 'storage_account': {'required': True}, - 'container_name': {'required': True}, - 'backup_name': {'required': True}, + "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'}, + "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__( @@ -1814,24 +1855,23 @@ def __init__( storage_account: str, container_name: str, backup_name: str, - access_type: Optional[Union[str, "AccessType"]] = "AccessKey", + access_type: Union[str, "_models.AccessType"] = "AccessKey", access_key: Optional[str] = None, client_id: Optional[str] = None, **kwargs ): """ - :keyword storage_account: Required. The name of the Azure storage account (used to - place/retrieve the backup). + :keyword storage_account: The name of the Azure storage account (used to place/retrieve the + backup). Required. :paramtype storage_account: str - :keyword container_name: Required. The name of the blob container (used to place/retrieve the - backup). + :keyword container_name: The name of the blob container (used to place/retrieve the backup). + Required. :paramtype container_name: str - :keyword backup_name: Required. The name of the backup file to create/retrieve. + :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. Possible values - include: "AccessKey", "SystemAssignedManagedIdentity", "UserAssignedManagedIdentity". Default - value: "AccessKey". - :paramtype access_type: str or ~api_management_client.models.AccessType + :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 @@ -1839,7 +1879,7 @@ def __init__( ``accessType`` is set to ``UserAssignedManagedIdentity``. :paramtype client_id: str """ - super(ApiManagementServiceBackupRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.storage_account = storage_account self.container_name = container_name self.backup_name = backup_name @@ -1848,7 +1888,7 @@ def __init__( self.client_id = client_id -class ApiManagementServiceBaseProperties(msrest.serialization.Model): +class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Base Properties of an API Management service resource description. Variables are only populated by the server, and will be ignored when sending a request. @@ -1878,7 +1918,7 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): :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[~api_management_client.models.HostnameConfiguration] + :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] @@ -1893,14 +1933,14 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): :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'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -1931,7 +1971,7 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -1943,92 +1983,96 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", and "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion """ _validation = { - 'notification_sender_email': {'max_length': 100, 'min_length': 0}, - '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}, - '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'}, - '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'}, - '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'}, - } - - def __init__( + "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}, + "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"}, + "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"}, + "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"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, notification_sender_email: Optional[str] = None, - hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = 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["CertificateConfiguration"]] = None, - enable_client_certificate: Optional[bool] = False, - disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, - restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, + enable_client_certificate: bool = False, + disable_gateway: bool = False, + virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: bool = False, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, **kwargs ): """ :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[~api_management_client.models.HostnameConfiguration] + :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. @@ -2036,14 +2080,14 @@ def __init__( :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'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -2074,7 +2118,7 @@ def __init__( :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -2086,20 +2130,20 @@ def __init__( 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] """ - super(ApiManagementServiceBaseProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.notification_sender_email = notification_sender_email self.provisioning_state = None self.target_provisioning_state = None @@ -2128,38 +2172,33 @@ def __init__( self.platform_version = None -class ApiManagementServiceCheckNameAvailabilityParameters(msrest.serialization.Model): +class ApiManagementServiceCheckNameAvailabilityParameters(_serialization.Model): """Parameters supplied to the CheckNameAvailability operation. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name to check for availability. + :ivar name: The name to check for availability. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name to check for availability. + :keyword name: The name to check for availability. Required. :paramtype name: str """ - super(ApiManagementServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ApiManagementServiceGetDomainOwnershipIdentifierResult(msrest.serialization.Model): +class ApiManagementServiceGetDomainOwnershipIdentifierResult(_serialization.Model): """Response of the GetDomainOwnershipIdentifier operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2169,24 +2208,20 @@ class ApiManagementServiceGetDomainOwnershipIdentifierResult(msrest.serializatio """ _validation = { - 'domain_ownership_identifier': {'readonly': True}, + "domain_ownership_identifier": {"readonly": True}, } _attribute_map = { - 'domain_ownership_identifier': {'key': 'domainOwnershipIdentifier', 'type': 'str'}, + "domain_ownership_identifier": {"key": "domainOwnershipIdentifier", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiManagementServiceGetDomainOwnershipIdentifierResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.domain_ownership_identifier = None -class ApiManagementServiceGetSsoTokenResult(msrest.serialization.Model): +class ApiManagementServiceGetSsoTokenResult(_serialization.Model): """The response of the GetSsoToken operation. :ivar redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. @@ -2194,35 +2229,30 @@ class ApiManagementServiceGetSsoTokenResult(msrest.serialization.Model): """ _attribute_map = { - 'redirect_uri': {'key': 'redirectUri', 'type': 'str'}, + "redirect_uri": {"key": "redirectUri", "type": "str"}, } - def __init__( - self, - *, - redirect_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, redirect_uri: Optional[str] = None, **kwargs): """ :keyword redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. :paramtype redirect_uri: str """ - super(ApiManagementServiceGetSsoTokenResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.redirect_uri = redirect_uri -class ApiManagementServiceIdentity(msrest.serialization.Model): +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 Azure. - :ivar type: Required. 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. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :vartype type: str or ~api_management_client.models.ApimIdentityType + :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. @@ -2233,91 +2263,87 @@ class ApiManagementServiceIdentity(msrest.serialization.Model): '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :vartype user_assigned_identities: dict[str, - ~api_management_client.models.UserIdentityProperties] + ~azure.mgmt.apimanagement.models.UserIdentityProperties] """ _validation = { - 'type': {'required': True}, - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "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}'}, + "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, "ApimIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Union[str, "_models.ApimIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ - :keyword type: Required. The type of identity used for the resource. The type 'SystemAssigned, + :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. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :paramtype type: str or ~api_management_client.models.ApimIdentityType + 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, - ~api_management_client.models.UserIdentityProperties] + ~azure.mgmt.apimanagement.models.UserIdentityProperties] """ - super(ApiManagementServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = None self.tenant_id = None self.user_assigned_identities = user_assigned_identities -class ApiManagementServiceListResult(msrest.serialization.Model): +class ApiManagementServiceListResult(_serialization.Model): """The response of the List API Management services operation. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Result of the List API Management services operation. - :vartype value: list[~api_management_client.models.ApiManagementServiceResource] + :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}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiManagementServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiManagementServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: List["ApiManagementServiceResource"], - next_link: Optional[str] = None, - **kwargs + self, *, value: List["_models.ApiManagementServiceResource"], next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Required. Result of the List API Management services operation. - :paramtype value: list[~api_management_client.models.ApiManagementServiceResource] + :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(ApiManagementServiceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): +class ApiManagementServiceNameAvailabilityResult(_serialization.Model): """Response of the CheckNameAvailability operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2332,42 +2358,39 @@ class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): :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. Possible values include: "Valid", - "Invalid", "AlreadyExists". - :vartype reason: str or ~api_management_client.models.NameAvailabilityReason + 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}, + "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'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, } - def __init__( - self, - *, - reason: Optional[Union[str, "NameAvailabilityReason"]] = None, - **kwargs - ): + def __init__(self, *, reason: Optional[Union[str, "_models.NameAvailabilityReason"]] = None, **kwargs): """ :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. Possible values include: "Valid", - "Invalid", "AlreadyExists". - :paramtype reason: str or ~api_management_client.models.NameAvailabilityReason + 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(ApiManagementServiceNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = None self.message = None self.reason = reason -class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): +class ApiManagementServiceProperties( + ApiManagementServiceBaseProperties +): # pylint: disable=too-many-instance-attributes """Properties of an API Management service resource description. Variables are only populated by the server, and will be ignored when sending a request. @@ -2399,7 +2422,7 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): :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[~api_management_client.models.HostnameConfiguration] + :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] @@ -2414,14 +2437,14 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): :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'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -2452,7 +2475,7 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -2464,102 +2487,106 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion - :ivar publisher_email: Required. Publisher email. + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", and "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar publisher_email: Publisher email. Required. :vartype publisher_email: str - :ivar publisher_name: Required. Publisher name. + :ivar publisher_name: Publisher name. Required. :vartype publisher_name: str """ _validation = { - 'notification_sender_email': {'max_length': 100, 'min_length': 0}, - '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}, - 'platform_version': {'readonly': True}, - 'publisher_email': {'required': True, 'max_length': 100, 'min_length': 0}, - 'publisher_name': {'required': True, 'max_length': 100, 'min_length': 0}, - } - - _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'}, - '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'}, - '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'}, - 'publisher_email': {'key': 'publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'publisherName', 'type': 'str'}, - } - - def __init__( + "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}, + "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"}, + "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"}, + "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"}, + "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["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = 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["CertificateConfiguration"]] = None, - enable_client_certificate: Optional[bool] = False, - disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, - restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, + enable_client_certificate: bool = False, + disable_gateway: bool = False, + virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: bool = False, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, **kwargs ): """ :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[~api_management_client.models.HostnameConfiguration] + :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. @@ -2567,14 +2594,14 @@ def __init__( :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'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -2605,7 +2632,7 @@ def __init__( :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -2617,29 +2644,45 @@ def __init__( 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :keyword publisher_email: Required. Publisher email. + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword publisher_email: Publisher email. Required. :paramtype publisher_email: str - :keyword publisher_name: Required. Publisher name. + :keyword publisher_name: Publisher name. Required. :paramtype publisher_name: str """ - super(ApiManagementServiceProperties, self).__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, virtual_network_configuration=virtual_network_configuration, additional_locations=additional_locations, custom_properties=custom_properties, certificates=certificates, enable_client_certificate=enable_client_certificate, disable_gateway=disable_gateway, virtual_network_type=virtual_network_type, api_version_constraint=api_version_constraint, restore=restore, private_endpoint_connections=private_endpoint_connections, **kwargs) + 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, + virtual_network_configuration=virtual_network_configuration, + additional_locations=additional_locations, + custom_properties=custom_properties, + certificates=certificates, + enable_client_certificate=enable_client_certificate, + disable_gateway=disable_gateway, + virtual_network_type=virtual_network_type, + api_version_constraint=api_version_constraint, + restore=restore, + private_endpoint_connections=private_endpoint_connections, + **kwargs + ) self.publisher_email = publisher_email self.publisher_name = publisher_name -class ApimResource(msrest.serialization.Model): +class ApimResource(_serialization.Model): """The Resource definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -2650,41 +2693,36 @@ class ApimResource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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 - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ApimResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.tags = tags -class ApiManagementServiceResource(ApimResource): +class ApiManagementServiceResource(ApimResource): # pylint: disable=too-many-instance-attributes """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. @@ -2697,15 +2735,15 @@ class ApiManagementServiceResource(ApimResource): :vartype name: str :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar sku: Required. SKU properties of the API Management service. - :vartype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :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: ~api_management_client.models.ApiManagementServiceIdentity + :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~api_management_client.models.SystemData - :ivar location: Required. Resource location. + :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 @@ -2736,7 +2774,7 @@ class ApiManagementServiceResource(ApimResource): :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[~api_management_client.models.HostnameConfiguration] + :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] @@ -2751,14 +2789,14 @@ class ApiManagementServiceResource(ApimResource): :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'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -2789,7 +2827,7 @@ class ApiManagementServiceResource(ApimResource): :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -2801,134 +2839,141 @@ class ApiManagementServiceResource(ApimResource): 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion - :ivar publisher_email: Required. Publisher email. + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", and "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar publisher_email: Publisher email. Required. :vartype publisher_email: str - :ivar publisher_name: Required. Publisher name. + :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, 'min_length': 0}, - '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}, - 'platform_version': {'readonly': True}, - 'publisher_email': {'required': True, 'max_length': 100, 'min_length': 0}, - 'publisher_name': {'required': True, 'max_length': 100, 'min_length': 0}, - } - - _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'}, - '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'}, - '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'}, - 'publisher_email': {'key': 'properties.publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'properties.publisherName', 'type': 'str'}, - } - - def __init__( - self, - *, - sku: "ApiManagementServiceSkuProperties", + "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}, + "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"}, + "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"}, + "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"}, + "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["ApiManagementServiceIdentity"] = None, + identity: Optional["_models.ApiManagementServiceIdentity"] = None, zones: Optional[List[str]] = None, notification_sender_email: Optional[str] = None, - hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = 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["CertificateConfiguration"]] = None, - enable_client_certificate: Optional[bool] = False, - disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, - restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, + enable_client_certificate: bool = False, + disable_gateway: bool = False, + virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: bool = False, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword sku: Required. SKU properties of the API Management service. - :paramtype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :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: ~api_management_client.models.ApiManagementServiceIdentity - :keyword location: Required. Resource location. + :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[~api_management_client.models.HostnameConfiguration] + :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. @@ -2936,14 +2981,14 @@ def __init__( :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'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -2974,7 +3019,7 @@ def __init__( :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -2986,24 +3031,24 @@ def __init__( 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :keyword publisher_email: Required. Publisher email. + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword publisher_email: Publisher email. Required. :paramtype publisher_email: str - :keyword publisher_name: Required. Publisher name. + :keyword publisher_name: Publisher name. Required. :paramtype publisher_name: str """ - super(ApiManagementServiceResource, self).__init__(tags=tags, **kwargs) + super().__init__(tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -3040,50 +3085,44 @@ def __init__( self.publisher_name = publisher_name -class ApiManagementServiceSkuProperties(msrest.serialization.Model): +class ApiManagementServiceSkuProperties(_serialization.Model): """API Management service resource SKU properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the Sku. Possible values include: "Developer", "Standard", - "Premium", "Basic", "Consumption", "Isolated". - :vartype name: str or ~api_management_client.models.SkuType - :ivar capacity: Required. Capacity of the SKU (number of deployed units of the SKU). For - Consumption SKU capacity must be specified as 0. + :ivar name: Name of the Sku. Required. Known values are: "Developer", "Standard", "Premium", + "Basic", "Consumption", and "Isolated". + :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}, + "name": {"required": True}, + "capacity": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } - def __init__( - self, - *, - name: Union[str, "SkuType"], - capacity: int, - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuType"], capacity: int, **kwargs): """ - :keyword name: Required. Name of the Sku. Possible values include: "Developer", "Standard", - "Premium", "Basic", "Consumption", "Isolated". - :paramtype name: str or ~api_management_client.models.SkuType - :keyword capacity: Required. Capacity of the SKU (number of deployed units of the SKU). For - Consumption SKU capacity must be specified as 0. + :keyword name: Name of the Sku. Required. Known values are: "Developer", "Standard", "Premium", + "Basic", "Consumption", and "Isolated". + :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(ApiManagementServiceSkuProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capacity = capacity -class ApiManagementServiceUpdateParameters(ApimResource): +class ApiManagementServiceUpdateParameters(ApimResource): # pylint: disable=too-many-instance-attributes """Parameter supplied to Update Api Management Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -3094,12 +3133,12 @@ class ApiManagementServiceUpdateParameters(ApimResource): :vartype name: str :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: SKU properties of the API Management service. - :vartype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :ivar identity: Managed service identity of the Api Management service. - :vartype identity: ~api_management_client.models.ApiManagementServiceIdentity + :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. @@ -3129,7 +3168,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): :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[~api_management_client.models.HostnameConfiguration] + :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] @@ -3144,14 +3183,14 @@ class ApiManagementServiceUpdateParameters(ApimResource): :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'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -3182,7 +3221,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -3194,21 +3233,21 @@ class ApiManagementServiceUpdateParameters(ApimResource): 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", and "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion :ivar publisher_email: Publisher email. :vartype publisher_email: str :ivar publisher_name: Publisher name. @@ -3216,104 +3255,111 @@ class ApiManagementServiceUpdateParameters(ApimResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'notification_sender_email': {'max_length': 100, 'min_length': 0}, - '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}, - 'platform_version': {'readonly': True}, - 'publisher_email': {'max_length': 100, 'min_length': 0}, - 'publisher_name': {'max_length': 100, 'min_length': 0}, - } - - _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'}, - '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'}, - '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'}, - 'publisher_email': {'key': 'properties.publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'properties.publisherName', 'type': 'str'}, - } - - def __init__( + "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}, + "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"}, + "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"}, + "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"}, + "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["ApiManagementServiceSkuProperties"] = None, - identity: Optional["ApiManagementServiceIdentity"] = 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["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = 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["CertificateConfiguration"]] = None, - enable_client_certificate: Optional[bool] = False, - disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, - restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, + enable_client_certificate: bool = False, + disable_gateway: bool = False, + virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: bool = False, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: SKU properties of the API Management service. - :paramtype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :keyword identity: Managed service identity of the Api Management service. - :paramtype identity: ~api_management_client.models.ApiManagementServiceIdentity + :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[~api_management_client.models.HostnameConfiguration] + :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. @@ -3321,14 +3367,14 @@ def __init__( :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'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -3359,7 +3405,7 @@ def __init__( :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -3371,24 +3417,24 @@ def __init__( 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :keyword publisher_email: Publisher email. :paramtype publisher_email: str :keyword publisher_name: Publisher name. :paramtype publisher_name: str """ - super(ApiManagementServiceUpdateParameters, self).__init__(tags=tags, **kwargs) + super().__init__(tags=tags, **kwargs) self.sku = sku self.identity = identity self.etag = None @@ -3423,7 +3469,9 @@ def __init__( self.publisher_name = publisher_name -class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): +class ApiManagementServiceUpdateProperties( + ApiManagementServiceBaseProperties +): # pylint: disable=too-many-instance-attributes """Properties of an API Management service resource description. Variables are only populated by the server, and will be ignored when sending a request. @@ -3453,7 +3501,7 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): :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[~api_management_client.models.HostnameConfiguration] + :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] @@ -3468,14 +3516,14 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): :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'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -3506,7 +3554,7 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -3518,21 +3566,21 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", and "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion :ivar publisher_email: Publisher email. :vartype publisher_email: str :ivar publisher_name: Publisher name. @@ -3540,71 +3588,74 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): """ _validation = { - 'notification_sender_email': {'max_length': 100, 'min_length': 0}, - '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}, - 'platform_version': {'readonly': True}, - 'publisher_email': {'max_length': 100, 'min_length': 0}, - 'publisher_name': {'max_length': 100, 'min_length': 0}, - } - - _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'}, - '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'}, - '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'}, - 'publisher_email': {'key': 'publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'publisherName', 'type': 'str'}, - } - - def __init__( + "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}, + "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"}, + "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"}, + "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"}, + "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["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = 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["CertificateConfiguration"]] = None, - enable_client_certificate: Optional[bool] = False, - disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, - restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, + enable_client_certificate: bool = False, + disable_gateway: bool = False, + virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: bool = False, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs @@ -3613,7 +3664,8 @@ def __init__( :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[~api_management_client.models.HostnameConfiguration] + :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. @@ -3621,14 +3673,14 @@ def __init__( :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'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :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 @@ -3659,7 +3711,7 @@ def __init__( :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[~api_management_client.models.CertificateConfiguration] + :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. @@ -3671,29 +3723,45 @@ def __init__( 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. Possible values include: "None", - "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + 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: ~api_management_client.models.ApiVersionConstraint + :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[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :keyword publisher_email: Publisher email. :paramtype publisher_email: str :keyword publisher_name: Publisher name. :paramtype publisher_name: str """ - super(ApiManagementServiceUpdateProperties, self).__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, virtual_network_configuration=virtual_network_configuration, additional_locations=additional_locations, custom_properties=custom_properties, certificates=certificates, enable_client_certificate=enable_client_certificate, disable_gateway=disable_gateway, virtual_network_type=virtual_network_type, api_version_constraint=api_version_constraint, restore=restore, private_endpoint_connections=private_endpoint_connections, **kwargs) + 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, + virtual_network_configuration=virtual_network_configuration, + additional_locations=additional_locations, + custom_properties=custom_properties, + certificates=certificates, + enable_client_certificate=enable_client_certificate, + disable_gateway=disable_gateway, + virtual_network_type=virtual_network_type, + api_version_constraint=api_version_constraint, + restore=restore, + private_endpoint_connections=private_endpoint_connections, + **kwargs + ) self.publisher_email = publisher_email self.publisher_name = publisher_name -class ApiManagementSku(msrest.serialization.Model): +class ApiManagementSku(_serialization.Model): # pylint: disable=too-many-instance-attributes """Describes an available ApiManagement SKU. Variables are only populated by the server, and will be ignored when sending a request. @@ -3713,62 +3781,58 @@ class ApiManagementSku(msrest.serialization.Model): :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: ~api_management_client.models.ApiManagementSkuCapacity + :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[~api_management_client.models.ApiManagementSkuLocationInfo] + :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[~api_management_client.models.ApiManagementSkuCosts] + :vartype costs: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCosts] :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~api_management_client.models.ApiManagementSkuCapabilities] + :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[~api_management_client.models.ApiManagementSkuRestrictions] + :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 - ): - """ - """ - super(ApiManagementSku, self).__init__(**kwargs) + "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): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.tier = None @@ -3784,7 +3848,7 @@ def __init__( self.restrictions = None -class ApiManagementSkuCapabilities(msrest.serialization.Model): +class ApiManagementSkuCapabilities(_serialization.Model): """Describes The SKU capabilities object. Variables are only populated by the server, and will be ignored when sending a request. @@ -3796,27 +3860,23 @@ class ApiManagementSkuCapabilities(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiManagementSkuCapabilities, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class ApiManagementSkuCapacity(msrest.serialization.Model): +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. @@ -3827,39 +3887,35 @@ class ApiManagementSkuCapacity(msrest.serialization.Model): :vartype maximum: int :ivar default: The default capacity. :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~api_management_client.models.ApiManagementSkuCapacityScaleType + :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}, + "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'}, + "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 - ): - """ - """ - super(ApiManagementSkuCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class ApiManagementSkuCosts(msrest.serialization.Model): +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. @@ -3867,36 +3923,32 @@ class ApiManagementSkuCosts(msrest.serialization.Model): :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: long + :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}, + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, } _attribute_map = { - 'meter_id': {'key': 'meterID', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterID", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiManagementSkuCosts, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.meter_id = None self.quantity = None self.extended_unit = None -class ApiManagementSkuLocationInfo(msrest.serialization.Model): +class ApiManagementSkuLocationInfo(_serialization.Model): """ApiManagementSkuLocationInfo. Variables are only populated by the server, and will be ignored when sending a request. @@ -3906,34 +3958,30 @@ class ApiManagementSkuLocationInfo(msrest.serialization.Model): :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[~api_management_client.models.ApiManagementSkuZoneDetails] + :vartype zone_details: list[~azure.mgmt.apimanagement.models.ApiManagementSkuZoneDetails] """ _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'zone_details': {'readonly': True}, + "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]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ApiManagementSkuZoneDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiManagementSkuLocationInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.zones = None self.zone_details = None -class ApiManagementSkuRestrictionInfo(msrest.serialization.Model): +class ApiManagementSkuRestrictionInfo(_serialization.Model): """ApiManagementSkuRestrictionInfo. Variables are only populated by the server, and will be ignored when sending a request. @@ -3945,111 +3993,98 @@ class ApiManagementSkuRestrictionInfo(msrest.serialization.Model): """ _validation = { - 'locations': {'readonly': True}, - 'zones': {'readonly': True}, + "locations": {"readonly": True}, + "zones": {"readonly": True}, } _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiManagementSkuRestrictionInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.locations = None self.zones = None -class ApiManagementSkuRestrictions(msrest.serialization.Model): +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. Possible values include: "Location", "Zone". - :vartype type: str or ~api_management_client.models.ApiManagementSkuRestrictionsType + :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: ~api_management_client.models.ApiManagementSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Possible values include: "QuotaId", + :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 - ~api_management_client.models.ApiManagementSkuRestrictionsReasonCode + ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, - 'restriction_info': {'readonly': True}, - 'reason_code': {'readonly': True}, + "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'}, + "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 - ): - """ - """ - super(ApiManagementSkuRestrictions, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.values = None self.restriction_info = None self.reason_code = None -class ApiManagementSkusResult(msrest.serialization.Model): +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 Azure. - :ivar value: Required. The list of skus available for the subscription. - :vartype value: list[~api_management_client.models.ApiManagementSku] + :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}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiManagementSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiManagementSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["ApiManagementSku"], - **kwargs - ): + def __init__(self, *, value: List["_models.ApiManagementSku"], **kwargs): """ - :keyword value: Required. The list of skus available for the subscription. - :paramtype value: list[~api_management_client.models.ApiManagementSku] + :keyword value: The list of skus available for the subscription. Required. + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiManagementSku] """ - super(ApiManagementSkusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ApiManagementSkuZoneDetails(msrest.serialization.Model): +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. @@ -4058,65 +4093,56 @@ class ApiManagementSkuZoneDetails(msrest.serialization.Model): :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[~api_management_client.models.ApiManagementSkuCapabilities] + :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] """ _validation = { - 'name': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ApiManagementSkuCapabilities]'}, + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ApiManagementSkuCapabilities]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiManagementSkuZoneDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.capabilities = None -class ApiReleaseCollection(msrest.serialization.Model): +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[~api_management_client.models.ApiReleaseContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiReleaseContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiReleaseContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiReleaseContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(ApiReleaseCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None @@ -4147,84 +4173,73 @@ class ApiReleaseContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date_time': {'readonly': True}, - 'updated_date_time': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, *, api_id: Optional[str] = None, notes: Optional[str] = None, **kwargs): """ :keyword api_id: Identifier of the API the release belongs to. :paramtype api_id: str :keyword notes: Release Notes. :paramtype notes: str """ - super(ApiReleaseContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.api_id = api_id self.created_date_time = None self.updated_date_time = None self.notes = notes -class ApiRevisionCollection(msrest.serialization.Model): +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[~api_management_client.models.ApiRevisionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiRevisionContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiRevisionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiRevisionContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(ApiRevisionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None -class ApiRevisionContract(msrest.serialization.Model): +class ApiRevisionContract(_serialization.Model): """Summary of revision metadata. Variables are only populated by the server, and will be ignored when sending a request. @@ -4250,34 +4265,30 @@ class ApiRevisionContract(msrest.serialization.Model): """ _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, 'min_length': 0}, - '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 - ): - """ - """ - super(ApiRevisionContract, self).__init__(**kwargs) + "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): + """ """ + super().__init__(**kwargs) self.api_id = None self.api_revision = None self.created_date_time = None @@ -4288,7 +4299,7 @@ def __init__( self.is_current = None -class ApiRevisionInfoContract(msrest.serialization.Model): +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. @@ -4298,19 +4309,19 @@ class ApiRevisionInfoContract(msrest.serialization.Model): :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: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { - 'api_version_name': {'max_length': 100, 'min_length': 0}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, + "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'}, + "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__( @@ -4319,7 +4330,7 @@ def __init__( source_api_id: Optional[str] = None, api_version_name: Optional[str] = None, api_revision_description: Optional[str] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, **kwargs ): """ @@ -4330,16 +4341,16 @@ def __init__( :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: ~api_management_client.models.ApiVersionSetContractDetails + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ - super(ApiRevisionInfoContract, self).__init__(**kwargs) + 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): +class ApiTagResourceContractProperties(ApiEntityBaseContract): # pylint: disable=too-many-instance-attributes """API contract properties for the Tag Resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -4347,12 +4358,13 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -4375,9 +4387,9 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar id: API identifier in the form /apis/{apiId}. :vartype id: str :ivar name: API name. @@ -4389,50 +4401,53 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): 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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - 'name': {'max_length': 300, 'min_length': 1}, - 'service_url': {'max_length': 2000, 'min_length': 1}, - 'path': {'max_length': 400, 'min_length': 0}, - } - - _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]'}, + "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["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -4441,13 +4456,13 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, - id: 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, "Protocol"]]] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, **kwargs ): """ @@ -4455,13 +4470,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -4482,9 +4496,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword id: API identifier in the form /apis/{apiId}. :paramtype id: str :keyword name: API name. @@ -4496,9 +4510,25 @@ def __init__( 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 ~api_management_client.models.Protocol] - """ - super(ApiTagResourceContractProperties, self).__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) + :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 @@ -4506,7 +4536,7 @@ def __init__( self.protocols = protocols -class ApiUpdateContract(msrest.serialization.Model): +class ApiUpdateContract(_serialization.Model): # pylint: disable=too-many-instance-attributes """API update contract details. Variables are only populated by the server, and will be ignored when sending a request. @@ -4514,12 +4544,13 @@ class ApiUpdateContract(msrest.serialization.Model): :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: ~api_management_client.models.AuthenticationSettingsContract + :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: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -4542,9 +4573,9 @@ class ApiUpdateContract(msrest.serialization.Model): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -4554,49 +4585,55 @@ class ApiUpdateContract(msrest.serialization.Model): 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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { - 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100, 'min_length': 0}, - 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256, 'min_length': 0}, - 'api_version_description': {'max_length': 256, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'service_url': {'max_length': 2000, 'min_length': 1}, - 'path': {'max_length': 400, 'min_length': 0}, - } - - _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]'}, + "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["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = 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, @@ -4605,12 +4642,12 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = 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, "Protocol"]]] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, **kwargs ): """ @@ -4618,13 +4655,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :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 @@ -4645,9 +4681,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :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. @@ -4657,9 +4693,9 @@ def __init__( 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 ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ - super(ApiUpdateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings self.subscription_key_parameter_names = subscription_key_parameter_names @@ -4681,7 +4717,7 @@ def __init__( self.protocols = protocols -class ApiVersionConstraint(msrest.serialization.Model): +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 @@ -4690,58 +4726,53 @@ class ApiVersionConstraint(msrest.serialization.Model): """ _attribute_map = { - 'min_api_version': {'key': 'minApiVersion', 'type': 'str'}, + "min_api_version": {"key": "minApiVersion", "type": "str"}, } - def __init__( - self, - *, - min_api_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, min_api_version: Optional[str] = None, **kwargs): """ :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(ApiVersionConstraint, self).__init__(**kwargs) + super().__init__(**kwargs) self.min_api_version = min_api_version -class ApiVersionSetCollection(msrest.serialization.Model): +class ApiVersionSetCollection(_serialization.Model): """Paged API Version Set list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ApiVersionSetContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApiVersionSetContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ApiVersionSetContract"]] = None, + value: Optional[List["_models.ApiVersionSetContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.ApiVersionSetContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(ApiVersionSetCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -4771,28 +4802,28 @@ class ApiVersionSetContract(Resource): :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. Possible values include: "Segment", "Query", "Header". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + 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}, + "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'}, + "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__( @@ -4802,7 +4833,7 @@ def __init__( version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, **kwargs ): """ @@ -4817,10 +4848,10 @@ def __init__( :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. Possible values include: "Segment", "Query", "Header". - :paramtype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", and "Header". + :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ - super(ApiVersionSetContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.version_query_name = version_query_name self.version_header_name = version_header_name @@ -4828,7 +4859,7 @@ def __init__( self.versioning_scheme = versioning_scheme -class ApiVersionSetContractDetails(msrest.serialization.Model): +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. @@ -4838,9 +4869,9 @@ class ApiVersionSetContractDetails(msrest.serialization.Model): :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. Possible values include: "Segment", "Query", "Header". + located in a HTTP request. Known values are: "Segment", "Query", and "Header". :vartype versioning_scheme: str or - ~api_management_client.models.ApiVersionSetContractDetailsVersioningScheme + ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. :vartype version_query_name: str @@ -4850,21 +4881,21 @@ class ApiVersionSetContractDetails(msrest.serialization.Model): """ _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'}, + "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, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, - versioning_scheme: Optional[Union[str, "ApiVersionSetContractDetailsVersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.ApiVersionSetContractDetailsVersioningScheme"]] = None, version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, **kwargs @@ -4878,9 +4909,9 @@ def __init__( :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. Possible values include: "Segment", "Query", "Header". + located in a HTTP request. Known values are: "Segment", "Query", and "Header". :paramtype versioning_scheme: str or - ~api_management_client.models.ApiVersionSetContractDetailsVersioningScheme + ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme :keyword version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. :paramtype version_query_name: str @@ -4888,7 +4919,7 @@ def __init__( versioningScheme is set to ``header``. :paramtype version_header_name: str """ - super(ApiVersionSetContractDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.description = description @@ -4897,7 +4928,7 @@ def __init__( self.version_header_name = version_header_name -class ApiVersionSetEntityBase(msrest.serialization.Model): +class ApiVersionSetEntityBase(_serialization.Model): """API Version set base parameters. :ivar description: Description of API Version Set. @@ -4911,14 +4942,14 @@ class ApiVersionSetEntityBase(msrest.serialization.Model): """ _validation = { - 'version_query_name': {'max_length': 100, 'min_length': 1}, - 'version_header_name': {'max_length': 100, 'min_length': 1}, + "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'}, + "description": {"key": "description", "type": "str"}, + "version_query_name": {"key": "versionQueryName", "type": "str"}, + "version_header_name": {"key": "versionHeaderName", "type": "str"}, } def __init__( @@ -4939,7 +4970,7 @@ def __init__( versioningScheme is set to ``header``. :paramtype version_header_name: str """ - super(ApiVersionSetEntityBase, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.version_query_name = version_query_name self.version_header_name = version_header_name @@ -4958,33 +4989,33 @@ class ApiVersionSetContractProperties(ApiVersionSetEntityBase): :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: Required. Name of API Version Set. + :ivar display_name: Name of API Version Set. Required. :vartype display_name: str - :ivar versioning_scheme: Required. An value that determines where the API Version identifier - will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + :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}, + "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'}, + "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, "VersioningScheme"], + versioning_scheme: Union[str, "_models.VersioningScheme"], description: Optional[str] = None, version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, @@ -4999,18 +5030,23 @@ def __init__( :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: Required. Name of API Version Set. + :keyword display_name: Name of API Version Set. Required. :paramtype display_name: str - :keyword versioning_scheme: Required. An value that determines where the API Version identifier - will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :paramtype versioning_scheme: str or ~api_management_client.models.VersioningScheme - """ - super(ApiVersionSetContractProperties, self).__init__(description=description, version_query_name=version_query_name, version_header_name=version_header_name, **kwargs) + :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(msrest.serialization.Model): +class ApiVersionSetUpdateParameters(_serialization.Model): """Parameters to update or create an API Version Set Contract. :ivar description: Description of API Version Set. @@ -5024,22 +5060,22 @@ class ApiVersionSetUpdateParameters(msrest.serialization.Model): :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. Possible values include: "Segment", "Query", "Header". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + 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}, + "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'}, + "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__( @@ -5049,7 +5085,7 @@ def __init__( version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, **kwargs ): """ @@ -5064,10 +5100,10 @@ def __init__( :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. Possible values include: "Segment", "Query", "Header". - :paramtype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", and "Header". + :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ - super(ApiVersionSetUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.version_query_name = version_query_name self.version_header_name = version_header_name @@ -5089,22 +5125,22 @@ class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): :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. Possible values include: "Segment", "Query", "Header". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + 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}, + "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'}, + "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__( @@ -5114,7 +5150,7 @@ def __init__( version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, **kwargs ): """ @@ -5129,15 +5165,20 @@ def __init__( :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. Possible values include: "Segment", "Query", "Header". - :paramtype versioning_scheme: str or ~api_management_client.models.VersioningScheme - """ - super(ApiVersionSetUpdateParametersProperties, self).__init__(description=description, version_query_name=version_query_name, version_header_name=version_header_name, **kwargs) + 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(msrest.serialization.Model): +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. @@ -5147,20 +5188,16 @@ class ArmIdWrapper(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ArmIdWrapper, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -5177,111 +5214,104 @@ class AssociationContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar provisioning_state: Provisioning state. The only acceptable values to pass in are None - and "created". The default value is None. + :ivar provisioning_state: Provisioning state. Default value is "created". :vartype provisioning_state: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ - :keyword provisioning_state: Provisioning state. The only acceptable values to pass in are None - and "created". The default value is None. + :keyword provisioning_state: Provisioning state. Default value is "created". :paramtype provisioning_state: str """ - super(AssociationContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class AuthenticationSettingsContract(msrest.serialization.Model): +class AuthenticationSettingsContract(_serialization.Model): """API Authentication Settings. :ivar o_auth2: OAuth2 Authentication settings. - :vartype o_auth2: ~api_management_client.models.OAuth2AuthenticationSettingsContract + :vartype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract :ivar openid: OpenID Connect Authentication Settings. - :vartype openid: ~api_management_client.models.OpenIdAuthenticationSettingsContract + :vartype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract """ _attribute_map = { - 'o_auth2': {'key': 'oAuth2', 'type': 'OAuth2AuthenticationSettingsContract'}, - 'openid': {'key': 'openid', 'type': 'OpenIdAuthenticationSettingsContract'}, + "o_auth2": {"key": "oAuth2", "type": "OAuth2AuthenticationSettingsContract"}, + "openid": {"key": "openid", "type": "OpenIdAuthenticationSettingsContract"}, } def __init__( self, *, - o_auth2: Optional["OAuth2AuthenticationSettingsContract"] = None, - openid: Optional["OpenIdAuthenticationSettingsContract"] = None, + o_auth2: Optional["_models.OAuth2AuthenticationSettingsContract"] = None, + openid: Optional["_models.OpenIdAuthenticationSettingsContract"] = None, **kwargs ): """ :keyword o_auth2: OAuth2 Authentication settings. - :paramtype o_auth2: ~api_management_client.models.OAuth2AuthenticationSettingsContract + :paramtype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract :keyword openid: OpenID Connect Authentication Settings. - :paramtype openid: ~api_management_client.models.OpenIdAuthenticationSettingsContract + :paramtype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract """ - super(AuthenticationSettingsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.o_auth2 = o_auth2 self.openid = openid -class AuthorizationServerCollection(msrest.serialization.Model): +class AuthorizationServerCollection(_serialization.Model): """Paged OAuth2 Authorization Servers list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.AuthorizationServerContract] + :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AuthorizationServerContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["AuthorizationServerContract"]] = None, + value: Optional[List["_models.AuthorizationServerContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.AuthorizationServerContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(AuthorizationServerCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class AuthorizationServerContract(Resource): +class AuthorizationServerContract(Resource): # pylint: disable=too-many-instance-attributes """External OAuth authorization server settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -5298,17 +5328,19 @@ class AuthorizationServerContract(Resource): :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 ~api_management_client.models.AuthorizationMethod] + :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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + :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 @@ -5322,7 +5354,7 @@ class AuthorizationServerContract(Resource): :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -5340,7 +5372,7 @@ class AuthorizationServerContract(Resource): :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 ~api_management_client.models.GrantType] + :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 @@ -5350,51 +5382,51 @@ class AuthorizationServerContract(Resource): """ _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'}, - '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'}, + "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"}, + "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, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = 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, "BearerTokenSendingMethod"]]] = 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, client_registration_endpoint: Optional[str] = None, authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "GrantType"]]] = None, + grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs @@ -5406,18 +5438,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5432,7 +5464,7 @@ def __init__( :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -5450,7 +5482,7 @@ def __init__( :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 ~api_management_client.models.GrantType] + :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 @@ -5458,7 +5490,7 @@ def __init__( value. :paramtype client_secret: str """ - super(AuthorizationServerContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods self.client_authentication_method = client_authentication_method @@ -5477,24 +5509,26 @@ def __init__( self.client_secret = client_secret -class AuthorizationServerContractBaseProperties(msrest.serialization.Model): +class AuthorizationServerContractBaseProperties(_serialization.Model): """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 ~api_management_client.models.AuthorizationMethod] + :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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + :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 @@ -5508,7 +5542,7 @@ class AuthorizationServerContractBaseProperties(msrest.serialization.Model): :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -5518,29 +5552,29 @@ class AuthorizationServerContractBaseProperties(msrest.serialization.Model): """ _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'}, + "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, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = 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, "BearerTokenSendingMethod"]]] = 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 @@ -5552,18 +5586,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5578,7 +5612,7 @@ def __init__( :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -5586,7 +5620,7 @@ def __init__( grant type is supported by this authorization server. Default resource owner password. :paramtype resource_owner_password: str """ - super(AuthorizationServerContractBaseProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods self.client_authentication_method = client_authentication_method @@ -5599,7 +5633,9 @@ def __init__( self.resource_owner_password = resource_owner_password -class AuthorizationServerContractProperties(AuthorizationServerContractBaseProperties): +class AuthorizationServerContractProperties( + AuthorizationServerContractBaseProperties +): # pylint: disable=too-many-instance-attributes """External OAuth authorization server settings Properties. All required parameters must be populated in order to send to Azure. @@ -5608,17 +5644,19 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope :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 ~api_management_client.models.AuthorizationMethod] + :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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + :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 @@ -5632,26 +5670,26 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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: Required. User-friendly authorization server name. + :ivar display_name: User-friendly authorization server name. Required. :vartype display_name: str - :ivar client_registration_endpoint: Required. Optional reference to a page where client or app + :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. + referenced. Required. :vartype client_registration_endpoint: str - :ivar authorization_endpoint: Required. OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. + :ivar authorization_endpoint: OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. Required. :vartype authorization_endpoint: str - :ivar grant_types: Required. Form of an authorization grant, which the client uses to request - the access token. - :vartype grant_types: list[str or ~api_management_client.models.GrantType] - :ivar client_id: Required. Client or app id registered with this authorization server. + :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 @@ -5660,30 +5698,30 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope """ _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'}, - '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'}, + "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"}, + "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__( @@ -5692,16 +5730,16 @@ def __init__( display_name: str, client_registration_endpoint: str, authorization_endpoint: str, - grant_types: List[Union[str, "GrantType"]], + grant_types: List[Union[str, "_models.GrantType"]], client_id: str, description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = 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, "BearerTokenSendingMethod"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, resource_owner_username: Optional[str] = None, resource_owner_password: Optional[str] = None, client_secret: Optional[str] = None, @@ -5714,18 +5752,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5740,33 +5778,45 @@ def __init__( :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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: Required. User-friendly authorization server name. + :keyword display_name: User-friendly authorization server name. Required. :paramtype display_name: str - :keyword client_registration_endpoint: Required. Optional reference to a page where client or - app registration for this authorization server is performed. Contains absolute URL to entity - being referenced. + :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: Required. OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. + :keyword authorization_endpoint: OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. Required. :paramtype authorization_endpoint: str - :keyword grant_types: Required. Form of an authorization grant, which the client uses to - request the access token. - :paramtype grant_types: list[str or ~api_management_client.models.GrantType] - :keyword client_id: Required. Client or app id registered with this authorization server. + :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(AuthorizationServerContractProperties, self).__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) + 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.client_registration_endpoint = client_registration_endpoint self.authorization_endpoint = authorization_endpoint @@ -5775,7 +5825,7 @@ def __init__( self.client_secret = client_secret -class AuthorizationServerSecretsContract(msrest.serialization.Model): +class AuthorizationServerSecretsContract(_serialization.Model): """OAuth Server Secrets Contract. :ivar client_secret: oAuth Authorization Server Secrets. @@ -5789,9 +5839,9 @@ class AuthorizationServerSecretsContract(msrest.serialization.Model): """ _attribute_map = { - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, - 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, - 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "resource_owner_username": {"key": "resourceOwnerUsername", "type": "str"}, + "resource_owner_password": {"key": "resourceOwnerPassword", "type": "str"}, } def __init__( @@ -5812,13 +5862,13 @@ def __init__( grant type is supported by this authorization server. Default resource owner password. :paramtype resource_owner_password: str """ - super(AuthorizationServerSecretsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_secret = client_secret self.resource_owner_username = resource_owner_username self.resource_owner_password = resource_owner_password -class AuthorizationServerUpdateContract(Resource): +class AuthorizationServerUpdateContract(Resource): # pylint: disable=too-many-instance-attributes """External OAuth authorization server settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -5835,17 +5885,19 @@ class AuthorizationServerUpdateContract(Resource): :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 ~api_management_client.models.AuthorizationMethod] + :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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + :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 @@ -5859,7 +5911,7 @@ class AuthorizationServerUpdateContract(Resource): :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -5877,7 +5929,7 @@ class AuthorizationServerUpdateContract(Resource): :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 ~api_management_client.models.GrantType] + :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 @@ -5887,51 +5939,51 @@ class AuthorizationServerUpdateContract(Resource): """ _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'}, - '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'}, + "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"}, + "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, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = 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, "BearerTokenSendingMethod"]]] = 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, client_registration_endpoint: Optional[str] = None, authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "GrantType"]]] = None, + grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs @@ -5943,18 +5995,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5969,7 +6021,7 @@ def __init__( :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -5987,7 +6039,7 @@ def __init__( :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 ~api_management_client.models.GrantType] + :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 @@ -5995,7 +6047,7 @@ def __init__( value. :paramtype client_secret: str """ - super(AuthorizationServerUpdateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods self.client_authentication_method = client_authentication_method @@ -6014,24 +6066,28 @@ def __init__( self.client_secret = client_secret -class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBaseProperties): +class AuthorizationServerUpdateContractProperties( + AuthorizationServerContractBaseProperties +): # pylint: disable=too-many-instance-attributes """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 ~api_management_client.models.AuthorizationMethod] + :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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + :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 @@ -6045,7 +6101,7 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -6063,7 +6119,7 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas :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 ~api_management_client.models.GrantType] + :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 @@ -6073,45 +6129,45 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas """ _validation = { - 'display_name': {'max_length': 50, 'min_length': 1}, + "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'}, - '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'}, + "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"}, + "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, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = 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, "BearerTokenSendingMethod"]]] = 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, client_registration_endpoint: Optional[str] = None, authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "GrantType"]]] = None, + grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs @@ -6123,18 +6179,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~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 - ~api_management_client.models.ClientAuthenticationMethod] + ~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[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -6149,7 +6205,7 @@ def __init__( :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 - ~api_management_client.models.BearerTokenSendingMethod] + ~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 @@ -6167,7 +6223,7 @@ def __init__( :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 ~api_management_client.models.GrantType] + :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 @@ -6175,7 +6231,19 @@ def __init__( value. :paramtype client_secret: str """ - super(AuthorizationServerUpdateContractProperties, self).__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) + 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.client_registration_endpoint = client_registration_endpoint self.authorization_endpoint = authorization_endpoint @@ -6184,46 +6252,40 @@ def __init__( self.client_secret = client_secret -class BackendAuthorizationHeaderCredentials(msrest.serialization.Model): +class BackendAuthorizationHeaderCredentials(_serialization.Model): """Authorization header information. All required parameters must be populated in order to send to Azure. - :ivar scheme: Required. Authentication Scheme name. + :ivar scheme: Authentication Scheme name. Required. :vartype scheme: str - :ivar parameter: Required. Authentication Parameter value. + :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}, + "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'}, + "scheme": {"key": "scheme", "type": "str"}, + "parameter": {"key": "parameter", "type": "str"}, } - def __init__( - self, - *, - scheme: str, - parameter: str, - **kwargs - ): + def __init__(self, *, scheme: str, parameter: str, **kwargs): """ - :keyword scheme: Required. Authentication Scheme name. + :keyword scheme: Authentication Scheme name. Required. :paramtype scheme: str - :keyword parameter: Required. Authentication Parameter value. + :keyword parameter: Authentication Parameter value. Required. :paramtype parameter: str """ - super(BackendAuthorizationHeaderCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.scheme = scheme self.parameter = parameter -class BackendBaseParameters(msrest.serialization.Model): +class BackendBaseParameters(_serialization.Model): """Backend entity base Parameter set. :ivar title: Backend Title. @@ -6234,29 +6296,29 @@ class BackendBaseParameters(msrest.serialization.Model): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties """ _validation = { - 'title': {'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 2000, 'min_length': 1}, - 'resource_id': {'max_length': 2000, 'min_length': 1}, + "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'}, + "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"}, } def __init__( @@ -6265,10 +6327,10 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, **kwargs ): """ @@ -6280,15 +6342,15 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties """ - super(BackendBaseParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.resource_id = resource_id @@ -6298,46 +6360,46 @@ def __init__( self.tls = tls -class BackendCollection(msrest.serialization.Model): +class BackendCollection(_serialization.Model): """Paged Backend list representation. :ivar value: Backend values. - :vartype value: list[~api_management_client.models.BackendContract] + :vartype value: list[~azure.mgmt.apimanagement.models.BackendContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BackendContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["BackendContract"]] = None, + value: Optional[List["_models.BackendContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Backend values. - :paramtype value: list[~api_management_client.models.BackendContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.BackendContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(BackendCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class BackendContract(Resource): +class BackendContract(Resource): # pylint: disable=too-many-instance-attributes """Backend details. Variables are only populated by the server, and will be ignored when sending a request. @@ -6358,42 +6420,42 @@ class BackendContract(Resource): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :ivar url: Runtime Url of the Backend. :vartype url: str - :ivar protocol: Backend communication protocol. Possible values include: "http", "soap". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :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'}, - 'url': {'key': 'properties.url', 'type': 'str'}, - 'protocol': {'key': 'properties.protocol', 'type': 'str'}, + "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"}, + "url": {"key": "properties.url", "type": "str"}, + "protocol": {"key": "properties.protocol", "type": "str"}, } def __init__( @@ -6402,12 +6464,12 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, url: Optional[str] = None, - protocol: Optional[Union[str, "BackendProtocol"]] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs ): """ @@ -6419,19 +6481,19 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :keyword url: Runtime Url of the Backend. :paramtype url: str - :keyword protocol: Backend communication protocol. Possible values include: "http", "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol + :keyword protocol: Backend communication protocol. Known values are: "http" and "soap". + :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ - super(BackendContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.resource_id = resource_id @@ -6456,52 +6518,51 @@ class BackendContractProperties(BackendBaseParameters): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties - :ivar url: Required. Runtime Url of the Backend. + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar url: Runtime Url of the Backend. Required. :vartype url: str - :ivar protocol: Required. Backend communication protocol. Possible values include: "http", - "soap". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :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}, + "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'}, - 'url': {'key': 'url', 'type': 'str'}, - 'protocol': {'key': 'protocol', 'type': 'str'}, + "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"}, + "url": {"key": "url", "type": "str"}, + "protocol": {"key": "protocol", "type": "str"}, } def __init__( self, *, url: str, - protocol: Union[str, "BackendProtocol"], + protocol: Union[str, "_models.BackendProtocol"], title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, **kwargs ): """ @@ -6513,25 +6574,34 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties - :keyword url: Required. Runtime Url of the Backend. + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :keyword url: Runtime Url of the Backend. Required. :paramtype url: str - :keyword protocol: Required. Backend communication protocol. Possible values include: "http", + :keyword protocol: Backend communication protocol. Required. Known values are: "http" and "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol - """ - super(BackendContractProperties, self).__init__(title=title, description=description, resource_id=resource_id, properties=properties, credentials=credentials, proxy=proxy, tls=tls, **kwargs) + :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, + **kwargs + ) self.url = url self.protocol = protocol -class BackendCredentialsContract(msrest.serialization.Model): +class BackendCredentialsContract(_serialization.Model): """Details of the Credentials used to connect to Backend. :ivar certificate_ids: List of Client Certificate Ids. @@ -6544,20 +6614,20 @@ class BackendCredentialsContract(msrest.serialization.Model): :ivar header: Header Parameter description. :vartype header: dict[str, list[str]] :ivar authorization: Authorization header authentication. - :vartype authorization: ~api_management_client.models.BackendAuthorizationHeaderCredentials + :vartype authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ _validation = { - 'certificate_ids': {'max_items': 32, 'min_items': 0}, - 'certificate': {'max_items': 32, 'min_items': 0}, + "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'}, + "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__( @@ -6567,7 +6637,7 @@ def __init__( certificate: Optional[List[str]] = None, query: Optional[Dict[str, List[str]]] = None, header: Optional[Dict[str, List[str]]] = None, - authorization: Optional["BackendAuthorizationHeaderCredentials"] = None, + authorization: Optional["_models.BackendAuthorizationHeaderCredentials"] = None, **kwargs ): """ @@ -6581,9 +6651,10 @@ def __init__( :keyword header: Header Parameter description. :paramtype header: dict[str, list[str]] :keyword authorization: Authorization header authentication. - :paramtype authorization: ~api_management_client.models.BackendAuthorizationHeaderCredentials + :paramtype authorization: + ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ - super(BackendCredentialsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate_ids = certificate_ids self.certificate = certificate self.query = query @@ -6591,40 +6662,37 @@ def __init__( self.authorization = authorization -class BackendProperties(msrest.serialization.Model): +class BackendProperties(_serialization.Model): """Properties specific to the Backend Type. :ivar service_fabric_cluster: Backend Service Fabric Cluster Properties. :vartype service_fabric_cluster: - ~api_management_client.models.BackendServiceFabricClusterProperties + ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties """ _attribute_map = { - 'service_fabric_cluster': {'key': 'serviceFabricCluster', 'type': 'BackendServiceFabricClusterProperties'}, + "service_fabric_cluster": {"key": "serviceFabricCluster", "type": "BackendServiceFabricClusterProperties"}, } def __init__( - self, - *, - service_fabric_cluster: Optional["BackendServiceFabricClusterProperties"] = None, - **kwargs + self, *, service_fabric_cluster: Optional["_models.BackendServiceFabricClusterProperties"] = None, **kwargs ): """ :keyword service_fabric_cluster: Backend Service Fabric Cluster Properties. :paramtype service_fabric_cluster: - ~api_management_client.models.BackendServiceFabricClusterProperties + ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties """ - super(BackendProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_fabric_cluster = service_fabric_cluster -class BackendProxyContract(msrest.serialization.Model): +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 Azure. - :ivar url: Required. WebProxy Server AbsoluteUri property which includes the entire URI stored - in the Uri instance, including all fragments and query strings. + :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 @@ -6633,33 +6701,26 @@ class BackendProxyContract(msrest.serialization.Model): """ _validation = { - 'url': {'required': True, 'max_length': 2000, 'min_length': 1}, + "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'}, + "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 - ): + def __init__(self, *, url: str, username: Optional[str] = None, password: Optional[str] = None, **kwargs): """ - :keyword url: Required. WebProxy Server AbsoluteUri property which includes the entire URI - stored in the Uri instance, including all fragments and query strings. + :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(BackendProxyContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.username = username self.password = password @@ -6684,34 +6745,29 @@ class BackendReconnectContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, *, after: Optional[datetime.timedelta] = None, **kwargs): """ :keyword after: Duration in ISO8601 format after which reconnect will be initiated. Minimum duration of the Reconnect is PT2M. :paramtype after: ~datetime.timedelta """ - super(BackendReconnectContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.after = after -class BackendServiceFabricClusterProperties(msrest.serialization.Model): +class BackendServiceFabricClusterProperties(_serialization.Model): """Properties of the Service Fabric Type Backend. All required parameters must be populated in order to send to Azure. @@ -6724,26 +6780,26 @@ class BackendServiceFabricClusterProperties(msrest.serialization.Model): :ivar max_partition_resolution_retries: Maximum number of retries while attempting resolve the partition. :vartype max_partition_resolution_retries: int - :ivar management_endpoints: Required. The cluster management endpoint. + :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[~api_management_client.models.X509CertificateName] + :vartype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] """ _validation = { - 'management_endpoints': {'required': True}, + "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]'}, + "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__( @@ -6754,7 +6810,7 @@ def __init__( client_certificatethumbprint: Optional[str] = None, max_partition_resolution_retries: Optional[int] = None, server_certificate_thumbprints: Optional[List[str]] = None, - server_x509_names: Optional[List["X509CertificateName"]] = None, + server_x509_names: Optional[List["_models.X509CertificateName"]] = None, **kwargs ): """ @@ -6766,15 +6822,15 @@ def __init__( :keyword max_partition_resolution_retries: Maximum number of retries while attempting resolve the partition. :paramtype max_partition_resolution_retries: int - :keyword management_endpoints: Required. The cluster management endpoint. + :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[~api_management_client.models.X509CertificateName] + :paramtype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] """ - super(BackendServiceFabricClusterProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_certificate_id = client_certificate_id self.client_certificatethumbprint = client_certificatethumbprint self.max_partition_resolution_retries = max_partition_resolution_retries @@ -6783,7 +6839,7 @@ def __init__( self.server_x509_names = server_x509_names -class BackendTlsProperties(msrest.serialization.Model): +class BackendTlsProperties(_serialization.Model): """Properties controlling TLS Certificate Validation. :ivar validate_certificate_chain: Flag indicating whether SSL certificate chain validation @@ -6795,17 +6851,11 @@ class BackendTlsProperties(msrest.serialization.Model): """ _attribute_map = { - 'validate_certificate_chain': {'key': 'validateCertificateChain', 'type': 'bool'}, - 'validate_certificate_name': {'key': 'validateCertificateName', 'type': 'bool'}, + "validate_certificate_chain": {"key": "validateCertificateChain", "type": "bool"}, + "validate_certificate_name": {"key": "validateCertificateName", "type": "bool"}, } - def __init__( - self, - *, - validate_certificate_chain: Optional[bool] = True, - validate_certificate_name: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, validate_certificate_chain: bool = True, validate_certificate_name: bool = True, **kwargs): """ :keyword validate_certificate_chain: Flag indicating whether SSL certificate chain validation should be done when using self-signed certificates for this backend host. @@ -6814,7 +6864,7 @@ def __init__( should be done when using self-signed certificates for this backend host. :paramtype validate_certificate_name: bool """ - super(BackendTlsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.validate_certificate_chain = validate_certificate_chain self.validate_certificate_name = validate_certificate_name @@ -6830,36 +6880,36 @@ class BackendUpdateParameterProperties(BackendBaseParameters): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :ivar url: Runtime Url of the Backend. :vartype url: str - :ivar protocol: Backend communication protocol. Possible values include: "http", "soap". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :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}, + "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'}, - 'url': {'key': 'url', 'type': 'str'}, - 'protocol': {'key': 'protocol', 'type': 'str'}, + "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"}, + "url": {"key": "url", "type": "str"}, + "protocol": {"key": "protocol", "type": "str"}, } def __init__( @@ -6868,12 +6918,12 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, url: Optional[str] = None, - protocol: Optional[Union[str, "BackendProtocol"]] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs ): """ @@ -6885,24 +6935,33 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :keyword url: Runtime Url of the Backend. :paramtype url: str - :keyword protocol: Backend communication protocol. Possible values include: "http", "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol - """ - super(BackendUpdateParameterProperties, self).__init__(title=title, description=description, resource_id=resource_id, properties=properties, credentials=credentials, proxy=proxy, tls=tls, **kwargs) + :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, + **kwargs + ) self.url = url self.protocol = protocol -class BackendUpdateParameters(msrest.serialization.Model): +class BackendUpdateParameters(_serialization.Model): """Backend update parameters. :ivar title: Backend Title. @@ -6913,36 +6972,36 @@ class BackendUpdateParameters(msrest.serialization.Model): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :ivar url: Runtime Url of the Backend. :vartype url: str - :ivar protocol: Backend communication protocol. Possible values include: "http", "soap". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :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}, + "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'}, - 'url': {'key': 'properties.url', 'type': 'str'}, - 'protocol': {'key': 'properties.protocol', '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"}, + "url": {"key": "properties.url", "type": "str"}, + "protocol": {"key": "properties.protocol", "type": "str"}, } def __init__( @@ -6951,12 +7010,12 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, url: Optional[str] = None, - protocol: Optional[Union[str, "BackendProtocol"]] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs ): """ @@ -6968,19 +7027,19 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :keyword url: Runtime Url of the Backend. :paramtype url: str - :keyword protocol: Backend communication protocol. Possible values include: "http", "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol + :keyword protocol: Backend communication protocol. Known values are: "http" and "soap". + :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ - super(BackendUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.resource_id = resource_id @@ -6992,7 +7051,7 @@ def __init__( self.protocol = protocol -class BodyDiagnosticSettings(msrest.serialization.Model): +class BodyDiagnosticSettings(_serialization.Model): """Body logging settings. :ivar bytes: Number of request body bytes to log. @@ -7000,61 +7059,56 @@ class BodyDiagnosticSettings(msrest.serialization.Model): """ _validation = { - 'bytes': {'maximum': 8192}, + "bytes": {"maximum": 8192}, } _attribute_map = { - 'bytes': {'key': 'bytes', 'type': 'int'}, + "bytes": {"key": "bytes", "type": "int"}, } - def __init__( - self, - *, - bytes: Optional[int] = None, - **kwargs - ): + def __init__(self, *, bytes: Optional[int] = None, **kwargs): """ :keyword bytes: Number of request body bytes to log. :paramtype bytes: int """ - super(BodyDiagnosticSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.bytes = bytes -class CacheCollection(msrest.serialization.Model): +class CacheCollection(_serialization.Model): """Paged Caches list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.CacheContract] + :vartype value: list[~azure.mgmt.apimanagement.models.CacheContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CacheContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["CacheContract"]] = None, + value: Optional[List["_models.CacheContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.CacheContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.CacheContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(CacheCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -7085,23 +7139,23 @@ class CacheContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'max_length': 2000, 'min_length': 0}, - 'connection_string': {'max_length': 300, 'min_length': 0}, - 'use_from_location': {'max_length': 256, 'min_length': 0}, - 'resource_id': {'max_length': 2000, 'min_length': 0}, + "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'}, + "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__( @@ -7124,14 +7178,14 @@ def __init__( :keyword resource_id: Original uri of entity in external system cache points to. :paramtype resource_id: str """ - super(CacheContract, self).__init__(**kwargs) + 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(msrest.serialization.Model): +class CacheUpdateParameters(_serialization.Model): """Cache update details. :ivar description: Cache description. @@ -7146,17 +7200,17 @@ class CacheUpdateParameters(msrest.serialization.Model): """ _validation = { - 'description': {'max_length': 2000, 'min_length': 0}, - 'connection_string': {'max_length': 300, 'min_length': 0}, - 'use_from_location': {'max_length': 256, 'min_length': 0}, - 'resource_id': {'max_length': 2000, 'min_length': 0}, + "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'}, + "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__( @@ -7179,53 +7233,53 @@ def __init__( :keyword resource_id: Original uri of entity in external system cache points to. :paramtype resource_id: str """ - super(CacheUpdateParameters, self).__init__(**kwargs) + 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(msrest.serialization.Model): +class CertificateCollection(_serialization.Model): """Paged Certificates list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.CertificateContract] + :vartype value: list[~azure.mgmt.apimanagement.models.CertificateContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CertificateContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["CertificateContract"]] = None, + value: Optional[List["_models.CertificateContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.CertificateContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.CertificateContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(CertificateCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class CertificateConfiguration(msrest.serialization.Model): +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 Azure. @@ -7234,32 +7288,32 @@ class CertificateConfiguration(msrest.serialization.Model): :vartype encoded_certificate: str :ivar certificate_password: Certificate Password. :vartype certificate_password: str - :ivar store_name: Required. The System.Security.Cryptography.x509certificates.StoreName - certificate store location. Only Root and CertificateAuthority are valid locations. Possible - values include: "CertificateAuthority", "Root". - :vartype store_name: str or ~api_management_client.models.CertificateConfigurationStoreName + :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: ~api_management_client.models.CertificateInformation + :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation """ _validation = { - 'store_name': {'required': True}, + "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'}, + "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, "CertificateConfigurationStoreName"], + store_name: Union[str, "_models.CertificateConfigurationStoreName"], encoded_certificate: Optional[str] = None, certificate_password: Optional[str] = None, - certificate: Optional["CertificateInformation"] = None, + certificate: Optional["_models.CertificateInformation"] = None, **kwargs ): """ @@ -7267,14 +7321,15 @@ def __init__( :paramtype encoded_certificate: str :keyword certificate_password: Certificate Password. :paramtype certificate_password: str - :keyword store_name: Required. The System.Security.Cryptography.x509certificates.StoreName - certificate store location. Only Root and CertificateAuthority are valid locations. Possible - values include: "CertificateAuthority", "Root". - :paramtype store_name: str or ~api_management_client.models.CertificateConfigurationStoreName + :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: ~api_management_client.models.CertificateInformation + :paramtype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation """ - super(CertificateConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.encoded_certificate = encoded_certificate self.certificate_password = certificate_password self.store_name = store_name @@ -7302,23 +7357,23 @@ class CertificateContract(Resource): 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: ~api_management_client.models.KeyVaultContractProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -7327,7 +7382,7 @@ def __init__( subject: Optional[str] = None, thumbprint: Optional[str] = None, expiration_date: Optional[datetime.datetime] = None, - key_vault: Optional["KeyVaultContractProperties"] = None, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, **kwargs ): """ @@ -7339,16 +7394,16 @@ def __init__( 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: ~api_management_client.models.KeyVaultContractProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ - super(CertificateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = subject self.thumbprint = thumbprint self.expiration_date = expiration_date self.key_vault = key_vault -class CertificateCreateOrUpdateParameters(msrest.serialization.Model): +class CertificateCreateOrUpdateParameters(_serialization.Model): """Certificate create or update details. :ivar data: Base 64 encoded certificate using the application/x-pkcs12 representation. @@ -7356,13 +7411,13 @@ class CertificateCreateOrUpdateParameters(msrest.serialization.Model): :ivar password: Password for the Certificate. :vartype password: str :ivar key_vault: KeyVault location details of the certificate. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :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'}, + "data": {"key": "properties.data", "type": "str"}, + "password": {"key": "properties.password", "type": "str"}, + "key_vault": {"key": "properties.keyVault", "type": "KeyVaultContractCreateProperties"}, } def __init__( @@ -7370,7 +7425,7 @@ def __init__( *, data: Optional[str] = None, password: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ @@ -7379,64 +7434,57 @@ def __init__( :keyword password: Password for the Certificate. :paramtype password: str :keyword key_vault: KeyVault location details of the certificate. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ - super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.data = data self.password = password self.key_vault = key_vault -class CertificateInformation(msrest.serialization.Model): +class CertificateInformation(_serialization.Model): """SSL certificate information. All required parameters must be populated in order to send to Azure. - :ivar expiry: Required. Expiration date of the certificate. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :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: Required. Thumbprint of the certificate. + :ivar thumbprint: Thumbprint of the certificate. Required. :vartype thumbprint: str - :ivar subject: Required. Subject of the certificate. + :ivar subject: Subject of the certificate. Required. :vartype subject: str """ _validation = { - 'expiry': {'required': True}, - 'thumbprint': {'required': True}, - 'subject': {'required': True}, + "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'}, + "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 - ): + def __init__(self, *, expiry: datetime.datetime, thumbprint: str, subject: str, **kwargs): """ - :keyword expiry: Required. Expiration date of the certificate. The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :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: Required. Thumbprint of the certificate. + :keyword thumbprint: Thumbprint of the certificate. Required. :paramtype thumbprint: str - :keyword subject: Required. Subject of the certificate. + :keyword subject: Subject of the certificate. Required. :paramtype subject: str """ - super(CertificateInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.expiry = expiry self.thumbprint = thumbprint self.subject = subject -class ClientSecretContract(msrest.serialization.Model): +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. @@ -7444,84 +7492,81 @@ class ClientSecretContract(msrest.serialization.Model): """ _attribute_map = { - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + "client_secret": {"key": "clientSecret", "type": "str"}, } - def __init__( - self, - *, - client_secret: Optional[str] = None, - **kwargs - ): + def __init__(self, *, client_secret: Optional[str] = None, **kwargs): """ :keyword client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. :paramtype client_secret: str """ - super(ClientSecretContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_secret = client_secret -class ConnectivityCheckRequest(msrest.serialization.Model): +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 Azure. - :ivar source: Required. Definitions about the connectivity check origin. - :vartype source: ~api_management_client.models.ConnectivityCheckRequestSource - :ivar destination: Required. The connectivity check operation destination. - :vartype destination: ~api_management_client.models.ConnectivityCheckRequestDestination - :ivar preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. Possible - values include: "IPv4". - :vartype preferred_ip_version: str or ~api_management_client.models.PreferredIPVersion + :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. Possible - values include: "TCP", "HTTP", "HTTPS". - :vartype protocol: str or ~api_management_client.models.ConnectivityCheckProtocol + 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: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration """ _validation = { - 'source': {'required': True}, - 'destination': {'required': True}, + "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'}, + "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: "ConnectivityCheckRequestSource", - destination: "ConnectivityCheckRequestDestination", - preferred_ip_version: Optional[Union[str, "PreferredIPVersion"]] = None, - protocol: Optional[Union[str, "ConnectivityCheckProtocol"]] = None, - protocol_configuration: Optional["ConnectivityCheckRequestProtocolConfiguration"] = None, + 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 ): """ - :keyword source: Required. Definitions about the connectivity check origin. - :paramtype source: ~api_management_client.models.ConnectivityCheckRequestSource - :keyword destination: Required. The connectivity check operation destination. - :paramtype destination: ~api_management_client.models.ConnectivityCheckRequestDestination + :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. - Possible values include: "IPv4". - :paramtype preferred_ip_version: str or ~api_management_client.models.PreferredIPVersion + "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. - Possible values include: "TCP", "HTTP", "HTTPS". - :paramtype protocol: str or ~api_management_client.models.ConnectivityCheckProtocol + 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: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration """ - super(ConnectivityCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.destination = destination self.preferred_ip_version = preferred_ip_version @@ -7529,201 +7574,188 @@ def __init__( self.protocol_configuration = protocol_configuration -class ConnectivityCheckRequestDestination(msrest.serialization.Model): +class ConnectivityCheckRequestDestination(_serialization.Model): """The connectivity check operation destination. All required parameters must be populated in order to send to Azure. - :ivar address: Required. Destination address. Can either be an IP address or a FQDN. + :ivar address: Destination address. Can either be an IP address or a FQDN. Required. :vartype address: str - :ivar port: Required. Destination port. - :vartype port: long + :ivar port: Destination port. Required. + :vartype port: int """ _validation = { - 'address': {'required': True}, - 'port': {'required': True}, + "address": {"required": True}, + "port": {"required": True}, } _attribute_map = { - 'address': {'key': 'address', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'long'}, + "address": {"key": "address", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - *, - address: str, - port: int, - **kwargs - ): + def __init__(self, *, address: str, port: int, **kwargs): """ - :keyword address: Required. Destination address. Can either be an IP address or a FQDN. + :keyword address: Destination address. Can either be an IP address or a FQDN. Required. :paramtype address: str - :keyword port: Required. Destination port. - :paramtype port: long + :keyword port: Destination port. Required. + :paramtype port: int """ - super(ConnectivityCheckRequestDestination, self).__init__(**kwargs) + super().__init__(**kwargs) self.address = address self.port = port -class ConnectivityCheckRequestProtocolConfiguration(msrest.serialization.Model): +class ConnectivityCheckRequestProtocolConfiguration(_serialization.Model): """Protocol-specific configuration. :ivar http_configuration: Configuration for HTTP or HTTPS requests. :vartype http_configuration: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration """ _attribute_map = { - 'http_configuration': {'key': 'HTTPConfiguration', 'type': 'ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration'}, + "http_configuration": { + "key": "HTTPConfiguration", + "type": "ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration", + }, } def __init__( self, *, - http_configuration: Optional["ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = None, + http_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = None, **kwargs ): """ :keyword http_configuration: Configuration for HTTP or HTTPS requests. :paramtype http_configuration: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration """ - super(ConnectivityCheckRequestProtocolConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.http_configuration = http_configuration -class ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration(msrest.serialization.Model): +class ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration(_serialization.Model): """Configuration for HTTP or HTTPS requests. - :ivar method: The HTTP method to be used. Possible values include: "GET", "POST". - :vartype method: str or ~api_management_client.models.Method + :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[long] + :vartype valid_status_codes: list[int] :ivar headers: List of headers to be included in the request. - :vartype headers: list[~api_management_client.models.HTTPHeader] + :vartype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] """ _attribute_map = { - 'method': {'key': 'method', 'type': 'str'}, - 'valid_status_codes': {'key': 'validStatusCodes', 'type': '[long]'}, - 'headers': {'key': 'headers', 'type': '[HTTPHeader]'}, + "method": {"key": "method", "type": "str"}, + "valid_status_codes": {"key": "validStatusCodes", "type": "[int]"}, + "headers": {"key": "headers", "type": "[HTTPHeader]"}, } def __init__( self, *, - method: Optional[Union[str, "Method"]] = None, + method: Optional[Union[str, "_models.Method"]] = None, valid_status_codes: Optional[List[int]] = None, - headers: Optional[List["HTTPHeader"]] = None, + headers: Optional[List["_models.HTTPHeader"]] = None, **kwargs ): """ - :keyword method: The HTTP method to be used. Possible values include: "GET", "POST". - :paramtype method: str or ~api_management_client.models.Method + :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[long] + :paramtype valid_status_codes: list[int] :keyword headers: List of headers to be included in the request. - :paramtype headers: list[~api_management_client.models.HTTPHeader] + :paramtype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] """ - super(ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.method = method self.valid_status_codes = valid_status_codes self.headers = headers -class ConnectivityCheckRequestSource(msrest.serialization.Model): +class ConnectivityCheckRequestSource(_serialization.Model): """Definitions about the connectivity check origin. All required parameters must be populated in order to send to Azure. - :ivar region: Required. The API Management service region from where to start the connectivity - check operation. + :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: long + :vartype instance: int """ _validation = { - 'region': {'required': True}, + "region": {"required": True}, } _attribute_map = { - 'region': {'key': 'region', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'long'}, + "region": {"key": "region", "type": "str"}, + "instance": {"key": "instance", "type": "int"}, } - def __init__( - self, - *, - region: str, - instance: Optional[int] = None, - **kwargs - ): + def __init__(self, *, region: str, instance: Optional[int] = None, **kwargs): """ - :keyword region: Required. The API Management service region from where to start the - connectivity check operation. + :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: long + :paramtype instance: int """ - super(ConnectivityCheckRequestSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.region = region self.instance = instance -class ConnectivityCheckResponse(msrest.serialization.Model): +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[~api_management_client.models.ConnectivityHop] - :ivar connection_status: The connection status. Possible values include: "Unknown", - "Connected", "Disconnected", "Degraded". - :vartype connection_status: str or ~api_management_client.models.ConnectionStatus + :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: long + :vartype avg_latency_in_ms: int :ivar min_latency_in_ms: Minimum latency in milliseconds. - :vartype min_latency_in_ms: long + :vartype min_latency_in_ms: int :ivar max_latency_in_ms: Maximum latency in milliseconds. - :vartype max_latency_in_ms: long + :vartype max_latency_in_ms: int :ivar probes_sent: Total number of probes sent. - :vartype probes_sent: long + :vartype probes_sent: int :ivar probes_failed: Number of failed probes. - :vartype probes_failed: long + :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}, + "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': 'long'}, - 'min_latency_in_ms': {'key': 'minLatencyInMs', 'type': 'long'}, - 'max_latency_in_ms': {'key': 'maxLatencyInMs', 'type': 'long'}, - 'probes_sent': {'key': 'probesSent', 'type': 'long'}, - 'probes_failed': {'key': 'probesFailed', 'type': 'long'}, + "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 - ): - """ - """ - super(ConnectivityCheckResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.hops = None self.connection_status = None self.avg_latency_in_ms = None @@ -7733,7 +7765,7 @@ def __init__( self.probes_failed = None -class ConnectivityHop(msrest.serialization.Model): +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. @@ -7749,34 +7781,30 @@ class ConnectivityHop(msrest.serialization.Model): :ivar next_hop_ids: List of next hop identifiers. :vartype next_hop_ids: list[str] :ivar issues: List of issues. - :vartype issues: list[~api_management_client.models.ConnectivityIssue] + :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}, + "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]'}, + "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 - ): - """ - """ - super(ConnectivityHop, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.id = None self.address = None @@ -7785,103 +7813,99 @@ def __init__( self.issues = None -class ConnectivityIssue(msrest.serialization.Model): +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. Possible values include: "Local", "Inbound", "Outbound". - :vartype origin: str or ~api_management_client.models.Origin - :ivar severity: The severity of the issue. Possible values include: "Error", "Warning". - :vartype severity: str or ~api_management_client.models.Severity - :ivar type: The type of issue. Possible values include: "Unknown", "AgentStopped", - "GuestFirewall", "DnsResolution", "SocketBind", "NetworkSecurityRule", "UserDefinedRoute", - "PortThrottled", "Platform". - :vartype type: str or ~api_management_client.models.IssueType + :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}, + "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}]'}, + "origin": {"key": "origin", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "context": {"key": "context", "type": "[{str}]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConnectivityIssue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.origin = None self.severity = None self.type = None self.context = None -class ConnectivityStatusContract(msrest.serialization.Model): +class ConnectivityStatusContract(_serialization.Model): """Details about connectivity to a resource. All required parameters must be populated in order to send to Azure. - :ivar name: Required. 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. + :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: Required. Resource Connectivity Status Type identifier. Possible values include: - "initializing", "success", "failure". - :vartype status: str or ~api_management_client.models.ConnectivityStatusType + :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: Required. 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 + :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. + ISO 8601 standard. Required. :vartype last_updated: ~datetime.datetime - :ivar last_status_change: Required. 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. + :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: Required. Resource Type. + :ivar resource_type: Resource Type. Required. :vartype resource_type: str - :ivar is_optional: Required. Whether this is optional. + :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}, + "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'}, + "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, "ConnectivityStatusType"], + status: Union[str, "_models.ConnectivityStatusType"], last_updated: datetime.datetime, last_status_change: datetime.datetime, resource_type: str, @@ -7890,30 +7914,30 @@ def __init__( **kwargs ): """ - :keyword name: Required. 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. + :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: Required. Resource Connectivity Status Type identifier. Possible values - include: "initializing", "success", "failure". - :paramtype status: str or ~api_management_client.models.ConnectivityStatusType + :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: Required. 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. + :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: Required. 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. + :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: Required. Resource Type. + :keyword resource_type: Resource Type. Required. :paramtype resource_type: str - :keyword is_optional: Required. Whether this is optional. + :keyword is_optional: Whether this is optional. Required. :paramtype is_optional: bool """ - super(ConnectivityStatusContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.status = status self.error = error @@ -7923,34 +7947,30 @@ def __init__( self.is_optional = is_optional -class ContentItemCollection(msrest.serialization.Model): +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[~api_management_client.models.ContentItemContract] + :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}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ContentItemContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ContentItemContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentItemCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -7973,60 +7993,51 @@ class ContentItemContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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 - ): + def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs): """ :keyword properties: Properties of the content item. :paramtype properties: dict[str, any] """ - super(ContentItemContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ContentTypeCollection(msrest.serialization.Model): +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[~api_management_client.models.ContentTypeContract] + :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}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ContentTypeContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ContentTypeContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContentTypeCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -8051,26 +8062,26 @@ class ContentTypeContract(Resource): :ivar description: Content type description. :vartype description: str :ivar schema: Content type schema. - :vartype schema: any + :vartype schema: JSON :ivar version: Content type version. :vartype version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -8079,7 +8090,7 @@ def __init__( id_properties_id: Optional[str] = None, name_properties_name: Optional[str] = None, description: Optional[str] = None, - schema: Optional[Any] = None, + schema: Optional[JSON] = None, version: Optional[str] = None, **kwargs ): @@ -8091,11 +8102,11 @@ def __init__( :keyword description: Content type description. :paramtype description: str :keyword schema: Content type schema. - :paramtype schema: any + :paramtype schema: JSON :keyword version: Content type version. :paramtype version: str """ - super(ContentTypeContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.id_properties_id = id_properties_id self.name_properties_name = name_properties_name self.description = description @@ -8103,66 +8114,62 @@ def __init__( self.version = version -class DataMasking(msrest.serialization.Model): +class DataMasking(_serialization.Model): """DataMasking. :ivar query_params: Masking settings for Url query parameters. - :vartype query_params: list[~api_management_client.models.DataMaskingEntity] + :vartype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] :ivar headers: Masking settings for headers. - :vartype headers: list[~api_management_client.models.DataMaskingEntity] + :vartype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] """ _attribute_map = { - 'query_params': {'key': 'queryParams', 'type': '[DataMaskingEntity]'}, - 'headers': {'key': 'headers', 'type': '[DataMaskingEntity]'}, + "query_params": {"key": "queryParams", "type": "[DataMaskingEntity]"}, + "headers": {"key": "headers", "type": "[DataMaskingEntity]"}, } def __init__( self, *, - query_params: Optional[List["DataMaskingEntity"]] = None, - headers: Optional[List["DataMaskingEntity"]] = None, + query_params: Optional[List["_models.DataMaskingEntity"]] = None, + headers: Optional[List["_models.DataMaskingEntity"]] = None, **kwargs ): """ :keyword query_params: Masking settings for Url query parameters. - :paramtype query_params: list[~api_management_client.models.DataMaskingEntity] + :paramtype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] :keyword headers: Masking settings for headers. - :paramtype headers: list[~api_management_client.models.DataMaskingEntity] + :paramtype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] """ - super(DataMasking, self).__init__(**kwargs) + super().__init__(**kwargs) self.query_params = query_params self.headers = headers -class DataMaskingEntity(msrest.serialization.Model): +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. Possible values include: "Mask", "Hide". - :vartype mode: str or ~api_management_client.models.DataMaskingMode + :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'}, + "value": {"key": "value", "type": "str"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( - self, - *, - value: Optional[str] = None, - mode: Optional[Union[str, "DataMaskingMode"]] = None, - **kwargs + self, *, value: Optional[str] = None, mode: Optional[Union[str, "_models.DataMaskingMode"]] = None, **kwargs ): """ :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. Possible values include: "Mask", "Hide". - :paramtype mode: str or ~api_management_client.models.DataMaskingMode + :keyword mode: Data masking mode. Known values are: "Mask" and "Hide". + :paramtype mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode """ - super(DataMaskingEntity, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.mode = mode @@ -8194,20 +8201,20 @@ class DeletedServiceContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "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'}, + "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__( @@ -8229,46 +8236,42 @@ def __init__( the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. :paramtype deletion_date: ~datetime.datetime """ - super(DeletedServiceContract, self).__init__(**kwargs) + 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(msrest.serialization.Model): +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[~api_management_client.models.DeletedServiceContract] + :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}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedServiceContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedServiceContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedServicesCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeployConfigurationParameters(msrest.serialization.Model): +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 @@ -8280,17 +8283,11 @@ class DeployConfigurationParameters(msrest.serialization.Model): """ _attribute_map = { - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'force': {'key': 'properties.force', 'type': 'bool'}, + "branch": {"key": "properties.branch", "type": "str"}, + "force": {"key": "properties.force", "type": "bool"}, } - def __init__( - self, - *, - branch: Optional[str] = None, - force: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, branch: Optional[str] = None, force: Optional[bool] = None, **kwargs): """ :keyword branch: The name of the Git branch from which the configuration is to be deployed to the configuration database. @@ -8299,51 +8296,51 @@ def __init__( update. :paramtype force: bool """ - super(DeployConfigurationParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.branch = branch self.force = force -class DiagnosticCollection(msrest.serialization.Model): +class DiagnosticCollection(_serialization.Model): """Paged Diagnostic list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.DiagnosticContract] + :vartype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DiagnosticContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["DiagnosticContract"]] = None, + value: Optional[List["_models.DiagnosticContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.DiagnosticContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(DiagnosticCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class DiagnosticContract(Resource): +class DiagnosticContract(Resource): # pylint: disable=too-many-instance-attributes """Diagnostic details. Variables are only populated by the server, and will be ignored when sending a request. @@ -8357,91 +8354,99 @@ class DiagnosticContract(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar always_log: Specifies for what type of messages sampling settings should not apply. - Possible values include: "allErrors". - :vartype always_log: str or ~api_management_client.models.AlwaysLog + "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: ~api_management_client.models.SamplingSettings + :vartype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings :ivar frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - :vartype frontend: ~api_management_client.models.PipelineDiagnosticSettings + :vartype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :ivar backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. - :vartype backend: ~api_management_client.models.PipelineDiagnosticSettings + :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. Possible values include: "None", "Legacy", "W3C". + diagnostics. Known values are: "None", "Legacy", and "W3C". :vartype http_correlation_protocol: str or - ~api_management_client.models.HttpCorrelationProtocol - :ivar verbosity: The verbosity level applied to traces emitted by trace policies. Possible - values include: "verbose", "information", "error". - :vartype verbosity: str or ~api_management_client.models.Verbosity + ~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. Possible values include: "Name", "Url". - :vartype operation_name_format: str or ~api_management_client.models.OperationNameFormat + 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}, + "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'}, + "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, "AlwaysLog"]] = None, + always_log: Optional[Union[str, "_models.AlwaysLog"]] = None, logger_id: Optional[str] = None, - sampling: Optional["SamplingSettings"] = None, - frontend: Optional["PipelineDiagnosticSettings"] = None, - backend: Optional["PipelineDiagnosticSettings"] = 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, "HttpCorrelationProtocol"]] = None, - verbosity: Optional[Union[str, "Verbosity"]] = None, - operation_name_format: Optional[Union[str, "OperationNameFormat"]] = 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 ): """ :keyword always_log: Specifies for what type of messages sampling settings should not apply. - Possible values include: "allErrors". - :paramtype always_log: str or ~api_management_client.models.AlwaysLog + "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: ~api_management_client.models.SamplingSettings + :paramtype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings :keyword frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - :paramtype frontend: ~api_management_client.models.PipelineDiagnosticSettings + :paramtype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :keyword backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. - :paramtype backend: ~api_management_client.models.PipelineDiagnosticSettings + :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. Possible values include: "None", "Legacy", "W3C". + diagnostics. Known values are: "None", "Legacy", and "W3C". :paramtype http_correlation_protocol: str or - ~api_management_client.models.HttpCorrelationProtocol - :keyword verbosity: The verbosity level applied to traces emitted by trace policies. Possible - values include: "verbose", "information", "error". - :paramtype verbosity: str or ~api_management_client.models.Verbosity + ~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. Possible values include: "Name", "Url". - :paramtype operation_name_format: str or ~api_management_client.models.OperationNameFormat + 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(DiagnosticContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.always_log = always_log self.logger_id = logger_id self.sampling = sampling @@ -8451,42 +8456,43 @@ def __init__( self.http_correlation_protocol = http_correlation_protocol self.verbosity = verbosity self.operation_name_format = operation_name_format + self.metrics = metrics -class EmailTemplateCollection(msrest.serialization.Model): +class EmailTemplateCollection(_serialization.Model): """Paged email template list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.EmailTemplateContract] + :vartype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EmailTemplateContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["EmailTemplateContract"]] = None, + value: Optional[List["_models.EmailTemplateContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.EmailTemplateContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(EmailTemplateCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -8518,28 +8524,28 @@ class EmailTemplateContract(Resource): :vartype is_default: bool :ivar parameters: Email Template Parameter values. :vartype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + 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}, + "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]'}, + "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__( @@ -8549,7 +8555,7 @@ def __init__( body: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, - parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, + parameters: Optional[List["_models.EmailTemplateParametersContractProperties"]] = None, **kwargs ): """ @@ -8563,9 +8569,9 @@ def __init__( :paramtype description: str :keyword parameters: Email Template Parameter values. :paramtype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ - super(EmailTemplateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = subject self.body = body self.title = title @@ -8574,7 +8580,7 @@ def __init__( self.parameters = parameters -class EmailTemplateParametersContractProperties(msrest.serialization.Model): +class EmailTemplateParametersContractProperties(_serialization.Model): """Email Template Parameter contract. :ivar name: Template parameter name. @@ -8586,24 +8592,19 @@ class EmailTemplateParametersContractProperties(msrest.serialization.Model): """ _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-._]+$'}, + "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'}, + "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 + self, *, name: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, **kwargs ): """ :keyword name: Template parameter name. @@ -8613,13 +8614,13 @@ def __init__( :keyword description: Template parameter description. :paramtype description: str """ - super(EmailTemplateParametersContractProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.title = title self.description = description -class EmailTemplateUpdateParameters(msrest.serialization.Model): +class EmailTemplateUpdateParameters(_serialization.Model): """Email Template update Parameters. :ivar subject: Subject of the Template. @@ -8632,20 +8633,20 @@ class EmailTemplateUpdateParameters(msrest.serialization.Model): :vartype body: str :ivar parameters: Email Template Parameter values. :vartype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ _validation = { - 'subject': {'max_length': 1000, 'min_length': 1}, - 'body': {'min_length': 1}, + "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]'}, + "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__( @@ -8655,7 +8656,7 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, body: Optional[str] = None, - parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, + parameters: Optional[List["_models.EmailTemplateParametersContractProperties"]] = None, **kwargs ): """ @@ -8669,9 +8670,9 @@ def __init__( :paramtype body: str :keyword parameters: Email Template Parameter values. :paramtype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ - super(EmailTemplateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = subject self.title = title self.description = description @@ -8679,39 +8680,39 @@ def __init__( self.parameters = parameters -class EndpointDependency(msrest.serialization.Model): +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[~api_management_client.models.EndpointDetail] + :vartype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] """ _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'endpoint_details': {'key': 'endpointDetails', 'type': '[EndpointDetail]'}, + "domain_name": {"key": "domainName", "type": "str"}, + "endpoint_details": {"key": "endpointDetails", "type": "[EndpointDetail]"}, } def __init__( self, *, domain_name: Optional[str] = None, - endpoint_details: Optional[List["EndpointDetail"]] = None, + endpoint_details: Optional[List["_models.EndpointDetail"]] = None, **kwargs ): """ :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[~api_management_client.models.EndpointDetail] + :paramtype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] """ - super(EndpointDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.endpoint_details = endpoint_details -class EndpointDetail(msrest.serialization.Model): +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. @@ -8721,29 +8722,23 @@ class EndpointDetail(msrest.serialization.Model): """ _attribute_map = { - 'port': {'key': 'port', 'type': 'int'}, - 'region': {'key': 'region', 'type': 'str'}, + "port": {"key": "port", "type": "int"}, + "region": {"key": "region", "type": "str"}, } - def __init__( - self, - *, - port: Optional[int] = None, - region: Optional[str] = None, - **kwargs - ): + def __init__(self, *, port: Optional[int] = None, region: Optional[str] = None, **kwargs): """ :keyword port: The port an endpoint is connected to. :paramtype port: int :keyword region: The region of the dependency. :paramtype region: str """ - super(EndpointDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.port = port self.region = region -class ErrorFieldContract(msrest.serialization.Model): +class ErrorFieldContract(_serialization.Model): """Error Field contract. :ivar code: Property level error code. @@ -8755,18 +8750,13 @@ class ErrorFieldContract(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "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 + self, *, code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, **kwargs ): """ :keyword code: Property level error code. @@ -8776,13 +8766,13 @@ def __init__( :keyword target: Property name. :paramtype target: str """ - super(ErrorFieldContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error Response. :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error @@ -8791,13 +8781,13 @@ class ErrorResponse(msrest.serialization.Model): :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[~api_management_client.models.ErrorFieldContract] + :vartype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ _attribute_map = { - 'code': {'key': 'error.code', 'type': 'str'}, - 'message': {'key': 'error.message', 'type': 'str'}, - 'details': {'key': 'error.details', 'type': '[ErrorFieldContract]'}, + "code": {"key": "error.code", "type": "str"}, + "message": {"key": "error.message", "type": "str"}, + "details": {"key": "error.details", "type": "[ErrorFieldContract]"}, } def __init__( @@ -8805,7 +8795,7 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["ErrorFieldContract"]] = None, + details: Optional[List["_models.ErrorFieldContract"]] = None, **kwargs ): """ @@ -8815,15 +8805,15 @@ def __init__( :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[~api_management_client.models.ErrorFieldContract] + :paramtype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error Body contract. :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error @@ -8832,13 +8822,13 @@ class ErrorResponseBody(msrest.serialization.Model): :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[~api_management_client.models.ErrorFieldContract] + :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]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorFieldContract]"}, } def __init__( @@ -8846,7 +8836,7 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["ErrorFieldContract"]] = None, + details: Optional[List["_models.ErrorFieldContract"]] = None, **kwargs ): """ @@ -8856,42 +8846,38 @@ def __init__( :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[~api_management_client.models.ErrorFieldContract] + :paramtype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class GatewayCertificateAuthorityCollection(msrest.serialization.Model): +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[~api_management_client.models.GatewayCertificateAuthorityContract] + :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}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayCertificateAuthorityContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayCertificateAuthorityContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayCertificateAuthorityCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -8914,67 +8900,57 @@ class GatewayCertificateAuthorityContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, *, is_trusted: Optional[bool] = None, **kwargs): """ :keyword is_trusted: Determines whether certificate authority is trusted. :paramtype is_trusted: bool """ - super(GatewayCertificateAuthorityContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_trusted = is_trusted -class GatewayCollection(msrest.serialization.Model): +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[~api_management_client.models.GatewayContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(GatewayCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None @@ -8994,72 +8970,68 @@ class GatewayContract(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar location_data: Gateway location. - :vartype location_data: ~api_management_client.models.ResourceLocationDataContract + :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, 'min_length': 0}, + "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'}, + "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["ResourceLocationDataContract"] = None, + location_data: Optional["_models.ResourceLocationDataContract"] = None, description: Optional[str] = None, **kwargs ): """ :keyword location_data: Gateway location. - :paramtype location_data: ~api_management_client.models.ResourceLocationDataContract + :paramtype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract :keyword description: Gateway description. :paramtype description: str """ - super(GatewayContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.location_data = location_data self.description = description -class GatewayHostnameConfigurationCollection(msrest.serialization.Model): +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[~api_management_client.models.GatewayHostnameConfigurationContract] + :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}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayHostnameConfigurationContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GatewayHostnameConfigurationContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GatewayHostnameConfigurationCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -9093,21 +9065,21 @@ class GatewayHostnameConfigurationContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -9136,7 +9108,7 @@ def __init__( :keyword http2_enabled: Specifies if HTTP/2.0 is supported. :paramtype http2_enabled: bool """ - super(GatewayHostnameConfigurationContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.hostname = hostname self.certificate_id = certificate_id self.negotiate_client_certificate = negotiate_client_certificate @@ -9145,40 +9117,35 @@ def __init__( self.http2_enabled = http2_enabled -class GatewayKeyRegenerationRequestContract(msrest.serialization.Model): +class GatewayKeyRegenerationRequestContract(_serialization.Model): """Gateway key regeneration request contract properties. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The Key being regenerated. Possible values include: "primary", + :ivar key_type: The Key being regenerated. Required. Known values are: "primary" and "secondary". - :vartype key_type: str or ~api_management_client.models.KeyType + :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "KeyType"], - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], **kwargs): """ - :keyword key_type: Required. The Key being regenerated. Possible values include: "primary", + :keyword key_type: The Key being regenerated. Required. Known values are: "primary" and "secondary". - :paramtype key_type: str or ~api_management_client.models.KeyType + :paramtype key_type: str or ~azure.mgmt.apimanagement.models.KeyType """ - super(GatewayKeyRegenerationRequestContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class GatewayKeysContract(msrest.serialization.Model): +class GatewayKeysContract(_serialization.Model): """Gateway authentication keys. :ivar primary: Primary gateway key. @@ -9188,29 +9155,23 @@ class GatewayKeysContract(msrest.serialization.Model): """ _attribute_map = { - 'primary': {'key': 'primary', 'type': 'str'}, - 'secondary': {'key': 'secondary', 'type': 'str'}, + "primary": {"key": "primary", "type": "str"}, + "secondary": {"key": "secondary", "type": "str"}, } - def __init__( - self, - *, - primary: Optional[str] = None, - secondary: Optional[str] = None, - **kwargs - ): + def __init__(self, *, primary: Optional[str] = None, secondary: Optional[str] = None, **kwargs): """ :keyword primary: Primary gateway key. :paramtype primary: str :keyword secondary: Secondary gateway key. :paramtype secondary: str """ - super(GatewayKeysContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary = primary self.secondary = secondary -class GatewayTokenContract(msrest.serialization.Model): +class GatewayTokenContract(_serialization.Model): """Gateway access token. :ivar value: Shared Access Authentication token value for the Gateway. @@ -9218,69 +9179,58 @@ class GatewayTokenContract(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, **kwargs): """ :keyword value: Shared Access Authentication token value for the Gateway. :paramtype value: str """ - super(GatewayTokenContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class GatewayTokenRequestContract(msrest.serialization.Model): +class GatewayTokenRequestContract(_serialization.Model): """Gateway token request contract properties. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The Key to be used to generate gateway token. Possible values - include: "primary", "secondary". - :vartype key_type: str or ~api_management_client.models.KeyType - :ivar expiry: Required. 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. + :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}, + "key_type": {"required": True}, + "expiry": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + "key_type": {"key": "keyType", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, } - def __init__( - self, - *, - key_type: Union[str, "KeyType"], - expiry: datetime.datetime, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], expiry: datetime.datetime, **kwargs): """ - :keyword key_type: Required. The Key to be used to generate gateway token. Possible values - include: "primary", "secondary". - :paramtype key_type: str or ~api_management_client.models.KeyType - :keyword expiry: Required. 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. + :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(GatewayTokenRequestContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.expiry = expiry -class GenerateSsoUrlResult(msrest.serialization.Model): +class GenerateSsoUrlResult(_serialization.Model): """Generate SSO Url operations response details. :ivar value: Redirect Url containing the SSO URL value. @@ -9288,58 +9238,48 @@ class GenerateSsoUrlResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, **kwargs): """ :keyword value: Redirect Url containing the SSO URL value. :paramtype value: str """ - super(GenerateSsoUrlResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class GlobalSchemaCollection(msrest.serialization.Model): +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[~api_management_client.models.GlobalSchemaContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GlobalSchemaContract] :ivar count: Total record count number. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GlobalSchemaContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GlobalSchemaContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number. - :paramtype count: long + :paramtype count: int """ - super(GlobalSchemaCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None @@ -9358,93 +9298,93 @@ class GlobalSchemaContract(Resource): :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. Possible values include: "xml", "json". - :vartype schema_type: str or ~api_management_client.models.SchemaType + :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: any + :vartype document: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, - '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'}, + "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"}, } def __init__( self, *, - schema_type: Optional[Union[str, "SchemaType"]] = None, + schema_type: Optional[Union[str, "_models.SchemaType"]] = None, description: Optional[str] = None, value: Optional[Any] = None, - document: Optional[Any] = None, + document: Optional[JSON] = None, **kwargs ): """ - :keyword schema_type: Schema Type. Immutable. Possible values include: "xml", "json". - :paramtype schema_type: str or ~api_management_client.models.SchemaType + :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: any + :paramtype document: JSON """ - super(GlobalSchemaContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.schema_type = schema_type self.description = description self.value = value self.document = document -class GroupCollection(msrest.serialization.Model): +class GroupCollection(_serialization.Model): """Paged Group list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.GroupContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GroupContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GroupContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["GroupContract"]] = None, + value: Optional[List["_models.GroupContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.GroupContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.GroupContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(GroupCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -9470,9 +9410,8 @@ class GroupContract(Resource): :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. Possible values include: "custom", "system", - "external". - :vartype type_properties_type: str or ~api_management_client.models.GroupType + :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. @@ -9480,23 +9419,23 @@ class GroupContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000, 'min_length': 0}, - 'built_in': {'readonly': True}, + "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'}, + "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__( @@ -9504,7 +9443,7 @@ def __init__( *, display_name: Optional[str] = None, description: Optional[str] = None, - type_properties_type: Optional[Union[str, "GroupType"]] = None, + type_properties_type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): @@ -9513,15 +9452,15 @@ def __init__( :paramtype display_name: str :keyword description: Group description. Can contain HTML formatting tags. :paramtype description: str - :keyword type_properties_type: Group type. Possible values include: "custom", "system", + :keyword type_properties_type: Group type. Known values are: "custom", "system", and "external". - :paramtype type_properties_type: str or ~api_management_client.models.GroupType + :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(GroupContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.description = description self.built_in = None @@ -9529,22 +9468,22 @@ def __init__( self.external_id = external_id -class GroupContractProperties(msrest.serialization.Model): +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 Azure. - :ivar display_name: Required. Group name. + :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. Possible values include: "custom", "system", "external". - :vartype type: str or ~api_management_client.models.GroupType + :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. @@ -9552,17 +9491,17 @@ class GroupContractProperties(msrest.serialization.Model): """ _validation = { - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000, 'min_length': 0}, - 'built_in': {'readonly': True}, + "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'}, + "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__( @@ -9570,23 +9509,23 @@ def __init__( *, display_name: str, description: Optional[str] = None, - type: Optional[Union[str, "GroupType"]] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): """ - :keyword display_name: Required. Group name. + :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. Possible values include: "custom", "system", "external". - :paramtype type: str or ~api_management_client.models.GroupType + :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(GroupContractProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.description = description self.built_in = None @@ -9594,15 +9533,15 @@ def __init__( self.external_id = external_id -class GroupCreateParameters(msrest.serialization.Model): +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. Possible values include: "custom", "system", "external". - :vartype type: str or ~api_management_client.models.GroupType + :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. @@ -9610,14 +9549,14 @@ class GroupCreateParameters(msrest.serialization.Model): """ _validation = { - 'display_name': {'max_length': 300, 'min_length': 1}, + "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'}, + "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__( @@ -9625,7 +9564,7 @@ def __init__( *, display_name: Optional[str] = None, description: Optional[str] = None, - type: Optional[Union[str, "GroupType"]] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): @@ -9634,29 +9573,29 @@ def __init__( :paramtype display_name: str :keyword description: Group description. :paramtype description: str - :keyword type: Group type. Possible values include: "custom", "system", "external". - :paramtype type: str or ~api_management_client.models.GroupType + :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(GroupCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.description = description self.type = type self.external_id = external_id -class GroupUpdateParameters(msrest.serialization.Model): +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. Possible values include: "custom", "system", "external". - :vartype type: str or ~api_management_client.models.GroupType + :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. @@ -9664,14 +9603,14 @@ class GroupUpdateParameters(msrest.serialization.Model): """ _validation = { - 'display_name': {'max_length': 300, 'min_length': 1}, + "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'}, + "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__( @@ -9679,7 +9618,7 @@ def __init__( *, display_name: Optional[str] = None, description: Optional[str] = None, - type: Optional[Union[str, "GroupType"]] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): @@ -9688,29 +9627,29 @@ def __init__( :paramtype display_name: str :keyword description: Group description. :paramtype description: str - :keyword type: Group type. Possible values include: "custom", "system", "external". - :paramtype type: str or ~api_management_client.models.GroupType + :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(GroupUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.description = description self.type = type self.external_id = external_id -class HostnameConfiguration(msrest.serialization.Model): +class HostnameConfiguration(_serialization.Model): # pylint: disable=too-many-instance-attributes """Custom hostname configuration. All required parameters must be populated in order to send to Azure. - :ivar type: Required. Hostname type. Possible values include: "Proxy", "Portal", "Management", - "Scm", "DeveloperPortal". - :vartype type: str or ~api_management_client.models.HostnameType - :ivar host_name: Required. Hostname to configure on the Api Management service. + :ivar type: Hostname type. Required. Known values are: "Proxy", "Portal", "Management", "Scm", + and "DeveloperPortal". + :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 @@ -9734,55 +9673,55 @@ class HostnameConfiguration(msrest.serialization.Model): hostname. Default Value is false. :vartype negotiate_client_certificate: bool :ivar certificate: Certificate information. - :vartype certificate: ~api_management_client.models.CertificateInformation - :ivar certificate_source: Certificate Source. Possible values include: "Managed", "KeyVault", - "Custom", "BuiltIn". - :vartype certificate_source: str or ~api_management_client.models.CertificateSource - :ivar certificate_status: Certificate Status. Possible values include: "Completed", "Failed", + :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 ~api_management_client.models.CertificateStatus + :vartype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus """ _validation = { - 'type': {'required': True}, - 'host_name': {'required': True}, + "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'}, + "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, "HostnameType"], + 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] = False, - negotiate_client_certificate: Optional[bool] = False, - certificate: Optional["CertificateInformation"] = None, - certificate_source: Optional[Union[str, "CertificateSource"]] = None, - certificate_status: Optional[Union[str, "CertificateStatus"]] = 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 ): """ - :keyword type: Required. Hostname type. Possible values include: "Proxy", "Portal", - "Management", "Scm", "DeveloperPortal". - :paramtype type: str or ~api_management_client.models.HostnameType - :keyword host_name: Required. Hostname to configure on the Api Management service. + :keyword type: Hostname type. Required. Known values are: "Proxy", "Portal", "Management", + "Scm", and "DeveloperPortal". + :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 @@ -9806,15 +9745,15 @@ def __init__( the hostname. Default Value is false. :paramtype negotiate_client_certificate: bool :keyword certificate: Certificate information. - :paramtype certificate: ~api_management_client.models.CertificateInformation - :keyword certificate_source: Certificate Source. Possible values include: "Managed", - "KeyVault", "Custom", "BuiltIn". - :paramtype certificate_source: str or ~api_management_client.models.CertificateSource - :keyword certificate_status: Certificate Status. Possible values include: "Completed", - "Failed", "InProgress". - :paramtype certificate_status: str or ~api_management_client.models.CertificateStatus - """ - super(HostnameConfiguration, self).__init__(**kwargs) + :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 @@ -9828,90 +9767,84 @@ def __init__( self.certificate_status = certificate_status -class HTTPHeader(msrest.serialization.Model): +class HTTPHeader(_serialization.Model): """HTTP header and it's value. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Header name. + :ivar name: Header name. Required. :vartype name: str - :ivar value: Required. Header value. + :ivar value: Header value. Required. :vartype value: str """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, value: str, **kwargs): """ - :keyword name: Required. Header name. + :keyword name: Header name. Required. :paramtype name: str - :keyword value: Required. Header value. + :keyword value: Header value. Required. :paramtype value: str """ - super(HTTPHeader, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class HttpMessageDiagnostic(msrest.serialization.Model): +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: ~api_management_client.models.BodyDiagnosticSettings + :vartype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings :ivar data_masking: Data masking settings. - :vartype data_masking: ~api_management_client.models.DataMasking + :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'}, + "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["BodyDiagnosticSettings"] = None, - data_masking: Optional["DataMasking"] = None, + body: Optional["_models.BodyDiagnosticSettings"] = None, + data_masking: Optional["_models.DataMasking"] = None, **kwargs ): """ :keyword headers: Array of HTTP Headers to log. :paramtype headers: list[str] :keyword body: Body logging settings. - :paramtype body: ~api_management_client.models.BodyDiagnosticSettings + :paramtype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings :keyword data_masking: Data masking settings. - :paramtype data_masking: ~api_management_client.models.DataMasking + :paramtype data_masking: ~azure.mgmt.apimanagement.models.DataMasking """ - super(HttpMessageDiagnostic, self).__init__(**kwargs) + super().__init__(**kwargs) self.headers = headers self.body = body self.data_masking = data_masking -class IdentityProviderBaseParameters(msrest.serialization.Model): +class IdentityProviderBaseParameters(_serialization.Model): """Identity Provider Base Parameter Properties. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -9931,28 +9864,28 @@ class IdentityProviderBaseParameters(msrest.serialization.Model): """ _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}, + "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}, } _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'}, + "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"}, } def __init__( self, *, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -9963,9 +9896,9 @@ def __init__( **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :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 @@ -9985,7 +9918,7 @@ def __init__( Identity Provider. :paramtype password_reset_policy_name: str """ - super(IdentityProviderBaseParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.signin_tenant = signin_tenant self.allowed_tenants = allowed_tenants @@ -9996,7 +9929,7 @@ def __init__( self.password_reset_policy_name = password_reset_policy_name -class IdentityProviderContract(Resource): +class IdentityProviderContract(Resource): # pylint: disable=too-many-instance-attributes """Identity Provider details. Variables are only populated by the server, and will be ignored when sending a request. @@ -10009,9 +9942,9 @@ class IdentityProviderContract(Resource): :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. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10039,38 +9972,38 @@ class IdentityProviderContract(Resource): """ _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_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_id': {'key': 'properties.clientId', 'type': 'str'}, - 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, + "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_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_id": {"key": "properties.clientId", "type": "str"}, + "client_secret": {"key": "properties.clientSecret", "type": "str"}, } def __init__( self, *, - type_properties_type: Optional[Union[str, "IdentityProviderType"]] = None, + type_properties_type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10083,9 +10016,9 @@ def __init__( **kwargs ): """ - :keyword type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :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 @@ -10113,7 +10046,7 @@ def __init__( Use '/listSecrets' POST request to get the value. :paramtype client_secret: str """ - super(IdentityProviderContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.type_properties_type = type_properties_type self.signin_tenant = signin_tenant self.allowed_tenants = allowed_tenants @@ -10131,9 +10064,9 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10150,8 +10083,8 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str - :ivar client_id: Required. 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. + :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 @@ -10161,33 +10094,33 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): """ _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_id': {'required': True, 'min_length': 1}, - 'client_secret': {'min_length': 1}, + "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_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_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + "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_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, } def __init__( self, *, client_id: str, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10199,9 +10132,9 @@ def __init__( **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :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 @@ -10220,8 +10153,8 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str - :keyword client_id: Required. 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. + :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 @@ -10229,12 +10162,22 @@ def __init__( Use '/listSecrets' POST request to get the value. :paramtype client_secret: str """ - super(IdentityProviderContractProperties, self).__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, **kwargs) + 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, + **kwargs + ) self.client_id = client_id self.client_secret = client_secret -class IdentityProviderCreateContract(Resource): +class IdentityProviderCreateContract(Resource): # pylint: disable=too-many-instance-attributes """Identity Provider details. Variables are only populated by the server, and will be ignored when sending a request. @@ -10247,9 +10190,9 @@ class IdentityProviderCreateContract(Resource): :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. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10277,38 +10220,38 @@ class IdentityProviderCreateContract(Resource): """ _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_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_id': {'key': 'properties.clientId', 'type': 'str'}, - 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, + "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_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_id": {"key": "properties.clientId", "type": "str"}, + "client_secret": {"key": "properties.clientSecret", "type": "str"}, } def __init__( self, *, - type_properties_type: Optional[Union[str, "IdentityProviderType"]] = None, + type_properties_type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10321,9 +10264,9 @@ def __init__( **kwargs ): """ - :keyword type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :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 @@ -10351,7 +10294,7 @@ def __init__( Use '/listSecrets' POST request to get the value. :paramtype client_secret: str """ - super(IdentityProviderCreateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.type_properties_type = type_properties_type self.signin_tenant = signin_tenant self.allowed_tenants = allowed_tenants @@ -10369,9 +10312,9 @@ class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10388,37 +10331,37 @@ class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str - :ivar client_id: Required. 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. + :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: Required. 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. + :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_id': {'required': True, 'min_length': 1}, - 'client_secret': {'required': True, 'min_length': 1}, + "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_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_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + "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_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, } def __init__( @@ -10426,7 +10369,7 @@ def __init__( *, client_id: str, client_secret: str, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10437,9 +10380,9 @@ def __init__( **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :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 @@ -10458,65 +10401,75 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str - :keyword client_id: Required. 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. + :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: Required. 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. + :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(IdentityProviderCreateContractProperties, self).__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, **kwargs) + 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, + **kwargs + ) self.client_id = client_id self.client_secret = client_secret -class IdentityProviderList(msrest.serialization.Model): +class IdentityProviderList(_serialization.Model): """List of all the Identity Providers configured on the service instance. :ivar value: Identity Provider configuration values. - :vartype value: list[~api_management_client.models.IdentityProviderContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IdentityProviderContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["IdentityProviderContract"]] = None, + value: Optional[List["_models.IdentityProviderContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Identity Provider configuration values. - :paramtype value: list[~api_management_client.models.IdentityProviderContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(IdentityProviderList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class IdentityProviderUpdateParameters(msrest.serialization.Model): +class IdentityProviderUpdateParameters(_serialization.Model): """Parameters supplied to update Identity Provider. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10543,32 +10496,32 @@ class IdentityProviderUpdateParameters(msrest.serialization.Model): """ _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_id': {'min_length': 1}, - 'client_secret': {'min_length': 1}, + "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_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_id': {'key': 'properties.clientId', 'type': 'str'}, - 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, + "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_id": {"key": "properties.clientId", "type": "str"}, + "client_secret": {"key": "properties.clientSecret", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10581,9 +10534,9 @@ def __init__( **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :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 @@ -10610,7 +10563,7 @@ def __init__( Google login, Public Key for Microsoft. :paramtype client_secret: str """ - super(IdentityProviderUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.signin_tenant = signin_tenant self.allowed_tenants = allowed_tenants @@ -10626,9 +10579,9 @@ def __init__( class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): """Parameters supplied to the Update Identity Provider operation. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10655,32 +10608,32 @@ class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): """ _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_id': {'min_length': 1}, - 'client_secret': {'min_length': 1}, + "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_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_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + "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_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10693,9 +10646,9 @@ def __init__( **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :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 @@ -10722,46 +10675,51 @@ def __init__( Google login, Public Key for Microsoft. :paramtype client_secret: str """ - super(IdentityProviderUpdateProperties, self).__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, **kwargs) + 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, + **kwargs + ) self.client_id = client_id self.client_secret = client_secret -class IssueAttachmentCollection(msrest.serialization.Model): +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[~api_management_client.models.IssueAttachmentContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IssueAttachmentContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IssueAttachmentContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IssueAttachmentContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(IssueAttachmentCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None @@ -10790,18 +10748,18 @@ class IssueAttachmentContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -10821,87 +10779,77 @@ def __init__( :keyword content: An HTTP link or Base64-encoded binary data. :paramtype content: str """ - super(IssueAttachmentContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.content_format = content_format self.content = content -class IssueCollection(msrest.serialization.Model): +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[~api_management_client.models.IssueContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IssueContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IssueContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IssueContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(IssueCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None -class IssueCommentCollection(msrest.serialization.Model): +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[~api_management_client.models.IssueCommentContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IssueCommentContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IssueCommentContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IssueCommentContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(IssueCommentCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None @@ -10929,18 +10877,18 @@ class IssueCommentContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -10959,7 +10907,7 @@ def __init__( :keyword user_id: A resource identifier for the user who left the comment. :paramtype user_id: str """ - super(IssueCommentContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.text = text self.created_date = created_date self.user_id = user_id @@ -10980,9 +10928,9 @@ class IssueContract(Resource): :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. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :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. @@ -10994,28 +10942,28 @@ class IssueContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, @@ -11025,9 +10973,9 @@ def __init__( """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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. @@ -11037,7 +10985,7 @@ def __init__( :keyword user_id: A resource identifier for the user created the issue. :paramtype user_id: str """ - super(IssueContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_date = created_date self.state = state self.api_id = api_id @@ -11046,42 +10994,42 @@ def __init__( self.user_id = user_id -class IssueContractBaseProperties(msrest.serialization.Model): +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. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :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'}, + "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, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, **kwargs ): """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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(IssueContractBaseProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_date = created_date self.state = state self.api_id = api_id @@ -11094,32 +11042,32 @@ class IssueContractProperties(IssueContractBaseProperties): :ivar created_date: Date and time when the issue was created. :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :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: Required. The issue title. + :ivar title: The issue title. Required. :vartype title: str - :ivar description: Required. Text describing the issue. + :ivar description: Text describing the issue. Required. :vartype description: str - :ivar user_id: Required. A resource identifier for the user created the issue. + :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}, + "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'}, + "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__( @@ -11129,39 +11077,39 @@ def __init__( description: str, user_id: str, created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, **kwargs ): """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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: Required. The issue title. + :keyword title: The issue title. Required. :paramtype title: str - :keyword description: Required. Text describing the issue. + :keyword description: Text describing the issue. Required. :paramtype description: str - :keyword user_id: Required. A resource identifier for the user created the issue. + :keyword user_id: A resource identifier for the user created the issue. Required. :paramtype user_id: str """ - super(IssueContractProperties, self).__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) + 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(msrest.serialization.Model): +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. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :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. @@ -11173,19 +11121,19 @@ class IssueUpdateContract(msrest.serialization.Model): """ _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'}, + "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, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, @@ -11195,9 +11143,9 @@ def __init__( """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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. @@ -11207,7 +11155,7 @@ def __init__( :keyword user_id: A resource identifier for the user created the issue. :paramtype user_id: str """ - super(IssueUpdateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_date = created_date self.state = state self.api_id = api_id @@ -11221,9 +11169,9 @@ class IssueUpdateContractProperties(IssueContractBaseProperties): :ivar created_date: Date and time when the issue was created. :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :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. @@ -11235,19 +11183,19 @@ class IssueUpdateContractProperties(IssueContractBaseProperties): """ _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'}, + "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, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, @@ -11257,9 +11205,9 @@ def __init__( """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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. @@ -11269,46 +11217,40 @@ def __init__( :keyword user_id: A resource identifier for the user created the issue. :paramtype user_id: str """ - super(IssueUpdateContractProperties, self).__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) + 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(msrest.serialization.Model): +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: SystemAssignedIdentity or UserAssignedIdentity Client Id which will - be used to access key vault secret. + :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'}, + "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 - ): + def __init__(self, *, secret_identifier: Optional[str] = None, identity_client_id: Optional[str] = None, **kwargs): """ :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: SystemAssignedIdentity or UserAssignedIdentity Client Id which - will be used to access key vault secret. + :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(KeyVaultContractCreateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.secret_identifier = secret_identifier self.identity_client_id = identity_client_id @@ -11320,17 +11262,18 @@ class KeyVaultContractProperties(KeyVaultContractCreateProperties): 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: SystemAssignedIdentity or UserAssignedIdentity Client Id which will - be used to access key vault secret. + :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: ~api_management_client.models.KeyVaultLastAccessStatusContractProperties + :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'}, + "secret_identifier": {"key": "secretIdentifier", "type": "str"}, + "identity_client_id": {"key": "identityClientId", "type": "str"}, + "last_status": {"key": "lastStatus", "type": "KeyVaultLastAccessStatusContractProperties"}, } def __init__( @@ -11338,7 +11281,7 @@ def __init__( *, secret_identifier: Optional[str] = None, identity_client_id: Optional[str] = None, - last_status: Optional["KeyVaultLastAccessStatusContractProperties"] = None, + last_status: Optional["_models.KeyVaultLastAccessStatusContractProperties"] = None, **kwargs ): """ @@ -11346,18 +11289,18 @@ def __init__( 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: SystemAssignedIdentity or UserAssignedIdentity Client Id which - will be used to access key vault secret. + :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: - ~api_management_client.models.KeyVaultLastAccessStatusContractProperties + ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties """ - super(KeyVaultContractProperties, self).__init__(secret_identifier=secret_identifier, identity_client_id=identity_client_id, **kwargs) + super().__init__(secret_identifier=secret_identifier, identity_client_id=identity_client_id, **kwargs) self.last_status = last_status -class KeyVaultLastAccessStatusContractProperties(msrest.serialization.Model): +class KeyVaultLastAccessStatusContractProperties(_serialization.Model): """Issue contract Update Properties. :ivar code: Last status code for sync and refresh of secret from key vault. @@ -11370,9 +11313,9 @@ class KeyVaultLastAccessStatusContractProperties(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time_stamp_utc': {'key': 'timeStampUtc', 'type': 'iso-8601'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time_stamp_utc": {"key": "timeStampUtc", "type": "iso-8601"}, } def __init__( @@ -11392,46 +11335,46 @@ def __init__( format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :paramtype time_stamp_utc: ~datetime.datetime """ - super(KeyVaultLastAccessStatusContractProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.time_stamp_utc = time_stamp_utc -class LoggerCollection(msrest.serialization.Model): +class LoggerCollection(_serialization.Model): """Paged Logger list representation. :ivar value: Logger values. - :vartype value: list[~api_management_client.models.LoggerContract] + :vartype value: list[~azure.mgmt.apimanagement.models.LoggerContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[LoggerContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["LoggerContract"]] = None, + value: Optional[List["_models.LoggerContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Logger values. - :paramtype value: list[~api_management_client.models.LoggerContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.LoggerContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(LoggerCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -11450,9 +11393,9 @@ class LoggerContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :vartype logger_type: str or ~api_management_client.models.LoggerType + :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 @@ -11468,27 +11411,27 @@ class LoggerContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'max_length': 256, 'min_length': 0}, + "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'}, + "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, "LoggerType"]] = None, + logger_type: Optional[Union[str, "_models.LoggerType"]] = None, description: Optional[str] = None, credentials: Optional[Dict[str, str]] = None, is_buffered: Optional[bool] = None, @@ -11496,9 +11439,9 @@ def __init__( **kwargs ): """ - :keyword logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :paramtype logger_type: str or ~api_management_client.models.LoggerType + :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 @@ -11512,7 +11455,7 @@ def __init__( Azure Application Insights resource). :paramtype resource_id: str """ - super(LoggerContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.logger_type = logger_type self.description = description self.credentials = credentials @@ -11520,12 +11463,12 @@ def __init__( self.resource_id = resource_id -class LoggerUpdateContract(msrest.serialization.Model): +class LoggerUpdateContract(_serialization.Model): """Logger update contract. - :ivar logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :vartype logger_type: str or ~api_management_client.models.LoggerType + :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. @@ -11536,25 +11479,25 @@ class LoggerUpdateContract(msrest.serialization.Model): """ _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'}, + "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, "LoggerType"]] = None, + logger_type: Optional[Union[str, "_models.LoggerType"]] = None, description: Optional[str] = None, credentials: Optional[Dict[str, str]] = None, is_buffered: Optional[bool] = None, **kwargs ): """ - :keyword logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :paramtype logger_type: str or ~api_management_client.models.LoggerType + :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. @@ -11563,47 +11506,47 @@ def __init__( assumed to be true. :paramtype is_buffered: bool """ - super(LoggerUpdateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.logger_type = logger_type self.description = description self.credentials = credentials self.is_buffered = is_buffered -class NamedValueCollection(msrest.serialization.Model): +class NamedValueCollection(_serialization.Model): """Paged NamedValue list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.NamedValueContract] + :vartype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NamedValueContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["NamedValueContract"]] = None, + value: Optional[List["_models.NamedValueContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.NamedValueContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(NamedValueCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -11622,8 +11565,7 @@ class NamedValueContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -11636,27 +11578,27 @@ class NamedValueContract(Resource): '/listSecrets' POST request to get the value. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _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, 'min_length': 0}, + "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': 'KeyVaultContractProperties'}, + "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"}, } def __init__( @@ -11666,12 +11608,11 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractProperties"] = None, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -11684,9 +11625,9 @@ def __init__( '/listSecrets' POST request to get the value. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ - super(NamedValueContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.secret = secret self.display_name = display_name @@ -11694,11 +11635,10 @@ def __init__( self.key_vault = key_vault -class NamedValueEntityBaseParameters(msrest.serialization.Model): +class NamedValueEntityBaseParameters(_serialization.Model): """NamedValue Entity Base Parameters set. - :ivar tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -11706,30 +11646,23 @@ class NamedValueEntityBaseParameters(msrest.serialization.Model): """ _validation = { - 'tags': {'max_items': 32, 'min_items': 0}, + "tags": {"max_items": 32, "min_items": 0}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '[str]'}, - 'secret': {'key': 'secret', 'type': 'bool'}, + "tags": {"key": "tags", "type": "[str]"}, + "secret": {"key": "secret", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[List[str]] = None, - secret: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List[str]] = None, secret: Optional[bool] = None, **kwargs): """ - :keyword tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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(NamedValueEntityBaseParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.secret = secret @@ -11739,35 +11672,34 @@ class NamedValueContractProperties(NamedValueEntityBaseParameters): All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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: Required. Unique name of NamedValue. It may contain only letters, digits, - period, dash, and underscore characters. + :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: ~api_management_client.models.KeyVaultContractProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _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, 'min_length': 0}, + "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': 'KeyVaultContractProperties'}, + "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"}, } def __init__( @@ -11777,27 +11709,26 @@ def __init__( tags: Optional[List[str]] = None, secret: Optional[bool] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractProperties"] = None, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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: Required. Unique name of NamedValue. It may contain only letters, - digits, period, dash, and underscore characters. + :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: ~api_management_client.models.KeyVaultContractProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ - super(NamedValueContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) + super().__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name self.value = value self.key_vault = key_vault @@ -11816,8 +11747,7 @@ class NamedValueCreateContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -11830,27 +11760,27 @@ class NamedValueCreateContract(Resource): '/listSecrets' POST request to get the value. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :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, 'min_length': 0}, + "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'}, + "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__( @@ -11860,12 +11790,11 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -11878,9 +11807,9 @@ def __init__( '/listSecrets' POST request to get the value. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ - super(NamedValueCreateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.secret = secret self.display_name = display_name @@ -11893,35 +11822,34 @@ class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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: Required. Unique name of NamedValue. It may contain only letters, digits, - period, dash, and underscore characters. + :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: ~api_management_client.models.KeyVaultContractCreateProperties + :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, 'min_length': 0}, + "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'}, + "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__( @@ -11931,33 +11859,32 @@ def __init__( tags: Optional[List[str]] = None, secret: Optional[bool] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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: Required. Unique name of NamedValue. It may contain only letters, - digits, period, dash, and underscore characters. + :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: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ - super(NamedValueCreateContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) + super().__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name self.value = value self.key_vault = key_vault -class NamedValueSecretContract(msrest.serialization.Model): +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. @@ -11965,28 +11892,22 @@ class NamedValueSecretContract(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, **kwargs): """ :keyword value: This is secret value of the NamedValue entity. :paramtype value: str """ - super(NamedValueSecretContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): """NamedValue Contract properties. - :ivar tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -11998,21 +11919,21 @@ class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): consist only of whitespace. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :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}, + "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'}, + "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__( @@ -12022,12 +11943,11 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -12039,19 +11959,18 @@ def __init__( consist only of whitespace. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ - super(NamedValueUpdateParameterProperties, self).__init__(tags=tags, secret=secret, **kwargs) + super().__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name self.value = value self.key_vault = key_vault -class NamedValueUpdateParameters(msrest.serialization.Model): +class NamedValueUpdateParameters(_serialization.Model): """NamedValue update Parameters. - :ivar tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -12063,21 +11982,21 @@ class NamedValueUpdateParameters(msrest.serialization.Model): consist only of whitespace. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :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}, + "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'}, + "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__( @@ -12087,12 +12006,11 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. + :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. @@ -12104,9 +12022,9 @@ def __init__( consist only of whitespace. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ - super(NamedValueUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.secret = secret self.display_name = display_name @@ -12114,117 +12032,114 @@ def __init__( self.key_vault = key_vault -class NetworkStatusContract(msrest.serialization.Model): +class NetworkStatusContract(_serialization.Model): """Network Status details. All required parameters must be populated in order to send to Azure. - :ivar dns_servers: Required. Gets the list of DNS servers IPV4 addresses. + :ivar dns_servers: Gets the list of DNS servers IPV4 addresses. Required. :vartype dns_servers: list[str] - :ivar connectivity_status: Required. Gets the list of Connectivity Status to the Resources on - which the service depends upon. - :vartype connectivity_status: list[~api_management_client.models.ConnectivityStatusContract] + :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}, + "dns_servers": {"required": True}, + "connectivity_status": {"required": True}, } _attribute_map = { - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - 'connectivity_status': {'key': 'connectivityStatus', 'type': '[ConnectivityStatusContract]'}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, + "connectivity_status": {"key": "connectivityStatus", "type": "[ConnectivityStatusContract]"}, } def __init__( - self, - *, - dns_servers: List[str], - connectivity_status: List["ConnectivityStatusContract"], - **kwargs + self, *, dns_servers: List[str], connectivity_status: List["_models.ConnectivityStatusContract"], **kwargs ): """ - :keyword dns_servers: Required. Gets the list of DNS servers IPV4 addresses. + :keyword dns_servers: Gets the list of DNS servers IPV4 addresses. Required. :paramtype dns_servers: list[str] - :keyword connectivity_status: Required. Gets the list of Connectivity Status to the Resources - on which the service depends upon. - :paramtype connectivity_status: list[~api_management_client.models.ConnectivityStatusContract] + :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(NetworkStatusContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.dns_servers = dns_servers self.connectivity_status = connectivity_status -class NetworkStatusContractByLocation(msrest.serialization.Model): +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: ~api_management_client.models.NetworkStatusContract + :vartype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract """ _validation = { - 'location': {'min_length': 1}, + "location": {"min_length": 1}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'network_status': {'key': 'networkStatus', 'type': 'NetworkStatusContract'}, + "location": {"key": "location", "type": "str"}, + "network_status": {"key": "networkStatus", "type": "NetworkStatusContract"}, } def __init__( self, *, location: Optional[str] = None, - network_status: Optional["NetworkStatusContract"] = None, + network_status: Optional["_models.NetworkStatusContract"] = None, **kwargs ): """ :keyword location: Location of service. :paramtype location: str :keyword network_status: Network status in Location. - :paramtype network_status: ~api_management_client.models.NetworkStatusContract + :paramtype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract """ - super(NetworkStatusContractByLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.network_status = network_status -class NotificationCollection(msrest.serialization.Model): +class NotificationCollection(_serialization.Model): """Paged Notification list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.NotificationContract] + :vartype value: list[~azure.mgmt.apimanagement.models.NotificationContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NotificationContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["NotificationContract"]] = None, + value: Optional[List["_models.NotificationContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.NotificationContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.NotificationContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(NotificationCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -12248,23 +12163,23 @@ class NotificationContract(Resource): :ivar description: Description of the Notification. :vartype description: str :ivar recipients: Recipient Parameter values. - :vartype recipients: ~api_management_client.models.RecipientsContractProperties + :vartype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'max_length': 1000, 'min_length': 1}, + "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'}, + "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__( @@ -12272,7 +12187,7 @@ def __init__( *, title: Optional[str] = None, description: Optional[str] = None, - recipients: Optional["RecipientsContractProperties"] = None, + recipients: Optional["_models.RecipientsContractProperties"] = None, **kwargs ): """ @@ -12281,15 +12196,15 @@ def __init__( :keyword description: Description of the Notification. :paramtype description: str :keyword recipients: Recipient Parameter values. - :paramtype recipients: ~api_management_client.models.RecipientsContractProperties + :paramtype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties """ - super(NotificationContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.title = title self.description = description self.recipients = recipients -class OAuth2AuthenticationSettingsContract(msrest.serialization.Model): +class OAuth2AuthenticationSettingsContract(_serialization.Model): """API OAuth2 Authentication settings details. :ivar authorization_server_id: OAuth authorization server identifier. @@ -12299,48 +12214,42 @@ class OAuth2AuthenticationSettingsContract(msrest.serialization.Model): """ _attribute_map = { - 'authorization_server_id': {'key': 'authorizationServerId', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, + "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 - ): + def __init__(self, *, authorization_server_id: Optional[str] = None, scope: Optional[str] = None, **kwargs): """ :keyword authorization_server_id: OAuth authorization server identifier. :paramtype authorization_server_id: str :keyword scope: operations scope. :paramtype scope: str """ - super(OAuth2AuthenticationSettingsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_server_id = authorization_server_id self.scope = scope -class OpenIdAuthenticationSettingsContract(msrest.serialization.Model): +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 - ~api_management_client.models.BearerTokenSendingMethods] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] """ _attribute_map = { - 'openid_provider_id': {'key': 'openidProviderId', 'type': 'str'}, - 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, + "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, "BearerTokenSendingMethods"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethods"]]] = None, **kwargs ): """ @@ -12348,47 +12257,47 @@ def __init__( :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 - ~api_management_client.models.BearerTokenSendingMethods] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] """ - super(OpenIdAuthenticationSettingsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.openid_provider_id = openid_provider_id self.bearer_token_sending_methods = bearer_token_sending_methods -class OpenIdConnectProviderCollection(msrest.serialization.Model): +class OpenIdConnectProviderCollection(_serialization.Model): """Paged OpenIdProviders list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.OpenidConnectProviderContract] + :vartype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OpenidConnectProviderContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["OpenidConnectProviderContract"]] = None, + value: Optional[List["_models.OpenidConnectProviderContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.OpenidConnectProviderContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(OpenIdConnectProviderCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -12420,21 +12329,21 @@ class OpenidConnectProviderContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 50, 'min_length': 0}, + "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'}, + "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"}, } def __init__( @@ -12459,7 +12368,7 @@ def __init__( :keyword client_secret: Client Secret of developer console which is the client application. :paramtype client_secret: str """ - super(OpenidConnectProviderContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.description = description self.metadata_endpoint = metadata_endpoint @@ -12467,7 +12376,7 @@ def __init__( self.client_secret = client_secret -class OpenidConnectProviderUpdateContract(msrest.serialization.Model): +class OpenidConnectProviderUpdateContract(_serialization.Model): """Parameters supplied to the Update OpenID Connect Provider operation. :ivar display_name: User-friendly OpenID Connect Provider name. @@ -12483,15 +12392,15 @@ class OpenidConnectProviderUpdateContract(msrest.serialization.Model): """ _validation = { - 'display_name': {'max_length': 50, 'min_length': 0}, + "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'}, + "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"}, } def __init__( @@ -12516,7 +12425,7 @@ def __init__( :keyword client_secret: Client Secret of developer console which is the client application. :paramtype client_secret: str """ - super(OpenidConnectProviderUpdateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.description = description self.metadata_endpoint = metadata_endpoint @@ -12524,93 +12433,88 @@ def __init__( self.client_secret = client_secret -class Operation(msrest.serialization.Model): +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: ~api_management_client.models.OperationDisplay + :vartype display: ~azure.mgmt.apimanagement.models.OperationDisplay :ivar origin: The operation origin. :vartype origin: str :ivar properties: The operation properties. - :vartype properties: any + :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'}, + "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["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that describes the operation. - :paramtype display: ~api_management_client.models.OperationDisplay + :paramtype display: ~azure.mgmt.apimanagement.models.OperationDisplay :keyword origin: The operation origin. :paramtype origin: str :keyword properties: The operation properties. - :paramtype properties: any + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.properties = properties -class OperationCollection(msrest.serialization.Model): +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[~api_management_client.models.OperationContract] + :vartype value: list[~azure.mgmt.apimanagement.models.OperationContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } - - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + + _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): """ :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(OperationCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None -class OperationContract(Resource): +class OperationContract(Resource): # pylint: disable=too-many-instance-attributes """API Operation details. Variables are only populated by the server, and will be ignored when sending a request. @@ -12624,13 +12528,13 @@ class OperationContract(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str :ivar display_name: Operation Name. @@ -12644,35 +12548,35 @@ class OperationContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'url_template': {'max_length': 1000, 'min_length': 1}, + "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'}, + "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["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = 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, @@ -12681,13 +12585,13 @@ def __init__( ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str :keyword display_name: Operation Name. @@ -12699,7 +12603,7 @@ def __init__( operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :paramtype url_template: str """ - super(OperationContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.template_parameters = template_parameters self.description = description self.request = request @@ -12710,56 +12614,56 @@ def __init__( self.url_template = url_template -class OperationEntityBaseContract(msrest.serialization.Model): +class OperationEntityBaseContract(_serialization.Model): """API Operation Entity Base Contract details. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str """ _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, + "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'}, + "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["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[List["_models.ResponseContract"]] = None, policies: Optional[str] = None, **kwargs ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str """ - super(OperationEntityBaseContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.template_parameters = template_parameters self.description = description self.request = request @@ -12773,41 +12677,41 @@ class OperationContractProperties(OperationEntityBaseContract): All required parameters must be populated in order to send to Azure. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str - :ivar display_name: Required. Operation Name. + :ivar display_name: Operation Name. Required. :vartype display_name: str - :ivar method: Required. A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST - but not limited by only them. + :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: Required. Relative URL template identifying the target resource for this - operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :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, 'min_length': 0}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'method': {'required': True}, - 'url_template': {'required': True, 'max_length': 1000, 'min_length': 1}, + "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'}, + "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__( @@ -12816,40 +12720,48 @@ def __init__( display_name: str, method: str, url_template: str, - template_parameters: Optional[List["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[List["_models.ResponseContract"]] = None, policies: Optional[str] = None, **kwargs ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str - :keyword display_name: Required. Operation Name. + :keyword display_name: Operation Name. Required. :paramtype display_name: str - :keyword method: Required. A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, - POST but not limited by only them. + :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: Required. Relative URL template identifying the target resource for this + :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(OperationContractProperties, self).__init__(template_parameters=template_parameters, description=description, request=request, responses=responses, policies=policies, **kwargs) + 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(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that describes the operation. :ivar provider: Friendly name of the resource provider. @@ -12863,10 +12775,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -12888,41 +12800,35 @@ def __init__( :keyword description: Friendly name of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.operation = operation self.resource = resource self.description = description -class OperationListResult(msrest.serialization.Model): +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[~api_management_client.models.Operation] + :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'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of operations supported by the resource provider. - :paramtype value: list[~api_management_client.models.Operation] + :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(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -12942,9 +12848,9 @@ class OperationResultContract(Resource): :vartype type: str :ivar id_properties_id: Operation result identifier. :vartype id_properties_id: str - :ivar status: Status of an async operation. Possible values include: "Started", "InProgress", - "Succeeded", "Failed". - :vartype status: str or ~api_management_client.models.AsyncOperationStatus + :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 @@ -12954,50 +12860,50 @@ class OperationResultContract(Resource): :ivar result_info: Optional result info. :vartype result_info: str :ivar error: Error Body Contract. - :vartype error: ~api_management_client.models.ErrorResponseBody + :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[~api_management_client.models.OperationResultLogItemContract] + :vartype action_log: list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'action_log': {'readonly': True}, + "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]'}, + "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, "AsyncOperationStatus"]] = 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["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ :keyword id_properties_id: Operation result identifier. :paramtype id_properties_id: str - :keyword status: Status of an async operation. Possible values include: "Started", - "InProgress", "Succeeded", "Failed". - :paramtype status: str or ~api_management_client.models.AsyncOperationStatus + :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 @@ -13007,9 +12913,9 @@ def __init__( :keyword result_info: Optional result info. :paramtype result_info: str :keyword error: Error Body Contract. - :paramtype error: ~api_management_client.models.ErrorResponseBody + :paramtype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody """ - super(OperationResultContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.id_properties_id = id_properties_id self.status = status self.started = started @@ -13019,7 +12925,7 @@ def __init__( self.action_log = None -class OperationResultLogItemContract(msrest.serialization.Model): +class OperationResultLogItemContract(_serialization.Model): """Log of the entity being created, updated or deleted. :ivar object_type: The type of entity contract. @@ -13031,9 +12937,9 @@ class OperationResultLogItemContract(msrest.serialization.Model): """ _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'object_key': {'key': 'objectKey', 'type': 'str'}, + "object_type": {"key": "objectType", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "object_key": {"key": "objectKey", "type": "str"}, } def __init__( @@ -13052,13 +12958,13 @@ def __init__( :keyword object_key: Identifier of the entity being created/updated/deleted. :paramtype object_key: str """ - super(OperationResultLogItemContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.object_type = object_type self.action = action self.object_key = object_key -class OperationTagResourceContractProperties(msrest.serialization.Model): +class OperationTagResourceContractProperties(_serialization.Model): """Operation Entity contract Properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -13084,37 +12990,32 @@ class OperationTagResourceContractProperties(msrest.serialization.Model): """ _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}, + "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'}, + "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 - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Identifier of the operation in form /operations/{operationId}. :paramtype id: str """ - super(OperationTagResourceContractProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = None self.api_name = None @@ -13125,17 +13026,17 @@ def __init__( self.url_template = None -class OperationUpdateContract(msrest.serialization.Model): +class OperationUpdateContract(_serialization.Model): """API Operation Update Contract details. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str :ivar display_name: Operation Name. @@ -13149,29 +13050,29 @@ class OperationUpdateContract(msrest.serialization.Model): """ _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'url_template': {'max_length': 1000, 'min_length': 1}, + "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'}, + "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["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = 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, @@ -13180,13 +13081,13 @@ def __init__( ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str :keyword display_name: Operation Name. @@ -13198,7 +13099,7 @@ def __init__( operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :paramtype url_template: str """ - super(OperationUpdateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.template_parameters = template_parameters self.description = description self.request = request @@ -13213,13 +13114,13 @@ class OperationUpdateContractProperties(OperationEntityBaseContract): """Operation Update Contract Properties. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str :ivar display_name: Operation Name. @@ -13233,29 +13134,29 @@ class OperationUpdateContractProperties(OperationEntityBaseContract): """ _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'url_template': {'max_length': 1000, 'min_length': 1}, + "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'}, + "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["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = 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, @@ -13264,13 +13165,13 @@ def __init__( ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :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: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str :keyword display_name: Operation Name. @@ -13282,32 +13183,39 @@ def __init__( operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :paramtype url_template: str """ - super(OperationUpdateContractProperties, self).__init__(template_parameters=template_parameters, description=description, request=request, responses=responses, policies=policies, **kwargs) + 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(msrest.serialization.Model): +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[~api_management_client.models.EndpointDependency] + :vartype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] """ _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'endpoints': {'key': 'endpoints', 'type': '[EndpointDependency]'}, + "category": {"key": "category", "type": "str"}, + "endpoints": {"key": "endpoints", "type": "[EndpointDependency]"}, } def __init__( self, *, category: Optional[str] = None, - endpoints: Optional[List["EndpointDependency"]] = None, + endpoints: Optional[List["_models.EndpointDependency"]] = None, **kwargs ): """ @@ -13315,61 +13223,56 @@ def __init__( 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[~api_management_client.models.EndpointDependency] + :paramtype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] """ - super(OutboundEnvironmentEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.endpoints = endpoints -class OutboundEnvironmentEndpointList(msrest.serialization.Model): +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 Azure. - :ivar value: Required. Collection of resources. - :vartype value: list[~api_management_client.models.OutboundEnvironmentEndpoint] + :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}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OutboundEnvironmentEndpoint]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OutboundEnvironmentEndpoint]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["OutboundEnvironmentEndpoint"], - **kwargs - ): + def __init__(self, *, value: List["_models.OutboundEnvironmentEndpoint"], **kwargs): """ - :keyword value: Required. Collection of resources. - :paramtype value: list[~api_management_client.models.OutboundEnvironmentEndpoint] + :keyword value: Collection of resources. Required. + :paramtype value: list[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] """ - super(OutboundEnvironmentEndpointList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ParameterContract(msrest.serialization.Model): +class ParameterContract(_serialization.Model): """Operation parameters details. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Parameter name. + :ivar name: Parameter name. Required. :vartype name: str :ivar description: Parameter description. :vartype description: str - :ivar type: Required. Parameter type. + :ivar type: Parameter type. Required. :vartype type: str :ivar default_value: Default parameter value. :vartype default_value: str @@ -13382,24 +13285,24 @@ class ParameterContract(msrest.serialization.Model): :ivar type_name: Type name defined by the schema. :vartype type_name: str :ivar examples: Exampled defined for the parameter. - :vartype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "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}'}, + "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__( @@ -13413,15 +13316,15 @@ def __init__( values: Optional[List[str]] = None, schema_id: Optional[str] = None, type_name: Optional[str] = None, - examples: Optional[Dict[str, "ParameterExampleContract"]] = None, + examples: Optional[Dict[str, "_models.ParameterExampleContract"]] = None, **kwargs ): """ - :keyword name: Required. Parameter name. + :keyword name: Parameter name. Required. :paramtype name: str :keyword description: Parameter description. :paramtype description: str - :keyword type: Required. Parameter type. + :keyword type: Parameter type. Required. :paramtype type: str :keyword default_value: Default parameter value. :paramtype default_value: str @@ -13434,9 +13337,9 @@ def __init__( :keyword type_name: Type name defined by the schema. :paramtype type_name: str :keyword examples: Exampled defined for the parameter. - :paramtype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ - super(ParameterContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.description = description self.type = type @@ -13448,7 +13351,7 @@ def __init__( self.examples = examples -class ParameterExampleContract(msrest.serialization.Model): +class ParameterExampleContract(_serialization.Model): """Parameter example. :ivar summary: Short description for the example. @@ -13462,10 +13365,10 @@ class ParameterExampleContract(msrest.serialization.Model): """ _attribute_map = { - 'summary': {'key': 'summary', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'object'}, - 'external_value': {'key': 'externalValue', 'type': 'str'}, + "summary": {"key": "summary", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "value": {"key": "value", "type": "object"}, + "external_value": {"key": "externalValue", "type": "str"}, } def __init__( @@ -13487,79 +13390,79 @@ def __init__( :keyword external_value: A URL that points to the literal example. :paramtype external_value: str """ - super(ParameterExampleContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.summary = summary self.description = description self.value = value self.external_value = external_value -class PipelineDiagnosticSettings(msrest.serialization.Model): +class PipelineDiagnosticSettings(_serialization.Model): """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. :ivar request: Diagnostic settings for request. - :vartype request: ~api_management_client.models.HttpMessageDiagnostic + :vartype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic :ivar response: Diagnostic settings for response. - :vartype response: ~api_management_client.models.HttpMessageDiagnostic + :vartype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic """ _attribute_map = { - 'request': {'key': 'request', 'type': 'HttpMessageDiagnostic'}, - 'response': {'key': 'response', 'type': 'HttpMessageDiagnostic'}, + "request": {"key": "request", "type": "HttpMessageDiagnostic"}, + "response": {"key": "response", "type": "HttpMessageDiagnostic"}, } def __init__( self, *, - request: Optional["HttpMessageDiagnostic"] = None, - response: Optional["HttpMessageDiagnostic"] = None, + request: Optional["_models.HttpMessageDiagnostic"] = None, + response: Optional["_models.HttpMessageDiagnostic"] = None, **kwargs ): """ :keyword request: Diagnostic settings for request. - :paramtype request: ~api_management_client.models.HttpMessageDiagnostic + :paramtype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic :keyword response: Diagnostic settings for response. - :paramtype response: ~api_management_client.models.HttpMessageDiagnostic + :paramtype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic """ - super(PipelineDiagnosticSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.request = request self.response = response -class PolicyCollection(msrest.serialization.Model): +class PolicyCollection(_serialization.Model): """The response of the list policy operation. :ivar value: Policy Contract value. - :vartype value: list[~api_management_client.models.PolicyContract] + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyContract] :ivar count: Total record count number. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PolicyContract"]] = None, + value: Optional[List["_models.PolicyContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Policy Contract value. - :paramtype value: list[~api_management_client.models.PolicyContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyContract] :keyword count: Total record count number. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(PolicyCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -13580,72 +13483,68 @@ class PolicyContract(Resource): :vartype type: str :ivar value: Contents of the Policy as defined by the format. :vartype value: str - :ivar format: Format of the policyContent. Possible values include: "xml", "xml-link", - "rawxml", "rawxml-link". Default value: "xml". - :vartype format: str or ~api_management_client.models.PolicyContentFormat + :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}, + "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'}, + "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: Optional[Union[str, "PolicyContentFormat"]] = "xml", - **kwargs + self, *, value: Optional[str] = None, format: Union[str, "_models.PolicyContentFormat"] = "xml", **kwargs ): """ :keyword value: Contents of the Policy as defined by the format. :paramtype value: str - :keyword format: Format of the policyContent. Possible values include: "xml", "xml-link", - "rawxml", "rawxml-link". Default value: "xml". - :paramtype format: str or ~api_management_client.models.PolicyContentFormat + :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(PolicyContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.format = format -class PolicyDescriptionCollection(msrest.serialization.Model): +class PolicyDescriptionCollection(_serialization.Model): """Descriptions of APIM policies. :ivar value: Descriptions of APIM policies. - :vartype value: list[~api_management_client.models.PolicyDescriptionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] :ivar count: Total record count number. - :vartype count: long + :vartype count: int """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDescriptionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, + "value": {"key": "value", "type": "[PolicyDescriptionContract]"}, + "count": {"key": "count", "type": "int"}, } def __init__( self, *, - value: Optional[List["PolicyDescriptionContract"]] = None, + value: Optional[List["_models.PolicyDescriptionContract"]] = None, count: Optional[int] = None, **kwargs ): """ :keyword value: Descriptions of APIM policies. - :paramtype value: list[~api_management_client.models.PolicyDescriptionContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] :keyword count: Total record count number. - :paramtype count: long + :paramtype count: int """ - super(PolicyDescriptionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count @@ -13666,32 +13565,28 @@ class PolicyDescriptionContract(Resource): :ivar description: Policy description. :vartype description: str :ivar scope: Binary OR value of the Snippet scope. - :vartype scope: long + :vartype scope: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'scope': {'readonly': True}, + "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': 'long'}, + "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 - ): - """ - """ - super(PolicyDescriptionContract, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.description = None self.scope = None @@ -13715,26 +13610,27 @@ class PortalDelegationSettings(Resource): from Azure API Management. :vartype validation_key: str :ivar subscriptions: Subscriptions delegation settings. - :vartype subscriptions: ~api_management_client.models.SubscriptionsDelegationSettingsProperties + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :ivar user_registration: User registration delegation settings. :vartype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -13742,8 +13638,8 @@ def __init__( *, url: Optional[str] = None, validation_key: Optional[str] = None, - subscriptions: Optional["SubscriptionsDelegationSettingsProperties"] = None, - user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, **kwargs ): """ @@ -13754,46 +13650,42 @@ def __init__( :paramtype validation_key: str :keyword subscriptions: Subscriptions delegation settings. :paramtype subscriptions: - ~api_management_client.models.SubscriptionsDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :keyword user_registration: User registration delegation settings. :paramtype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties """ - super(PortalDelegationSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.validation_key = validation_key self.subscriptions = subscriptions self.user_registration = user_registration -class PortalRevisionCollection(msrest.serialization.Model): +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[~api_management_client.models.PortalRevisionContract] + :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}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PortalRevisionContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PortalRevisionContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PortalRevisionCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -13815,9 +13707,9 @@ class PortalRevisionContract(Resource): :vartype description: str :ivar status_details: Portal revision publishing status details. :vartype status_details: str - :ivar status: Status of the portal's revision. Possible values include: "pending", - "publishing", "completed", "failed". - :vartype status: str or ~api_management_client.models.PortalRevisionStatus + :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. @@ -13827,42 +13719,36 @@ class PortalRevisionContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'max_length': 2000, 'min_length': 0}, - 'status_details': {'readonly': True, 'max_length': 2000, 'min_length': 0}, - 'status': {'readonly': True}, - 'created_date_time': {'readonly': True}, - 'updated_date_time': {'readonly': True}, + "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}, } _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'}, + "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"}, } - def __init__( - self, - *, - description: Optional[str] = None, - is_current: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, is_current: Optional[bool] = None, **kwargs): """ :keyword description: Portal revision description. :paramtype description: str :keyword is_current: Indicates if the portal's revision is public. :paramtype is_current: bool """ - super(PortalRevisionContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.status_details = None self.status = None @@ -13871,34 +13757,30 @@ def __init__( self.updated_date_time = None -class PortalSettingsCollection(msrest.serialization.Model): +class PortalSettingsCollection(_serialization.Model): """Descriptions of APIM policies. :ivar value: Descriptions of APIM policies. - :vartype value: list[~api_management_client.models.PortalSettingsContract] + :vartype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] :ivar count: Total record count number. - :vartype count: long + :vartype count: int """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PortalSettingsContract]'}, - 'count': {'key': 'count', 'type': 'long'}, + "value": {"key": "value", "type": "[PortalSettingsContract]"}, + "count": {"key": "count", "type": "int"}, } def __init__( - self, - *, - value: Optional[List["PortalSettingsContract"]] = None, - count: Optional[int] = None, - **kwargs + self, *, value: Optional[List["_models.PortalSettingsContract"]] = None, count: Optional[int] = None, **kwargs ): """ :keyword value: Descriptions of APIM policies. - :paramtype value: list[~api_management_client.models.PortalSettingsContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] :keyword count: Total record count number. - :paramtype count: long + :paramtype count: int """ - super(PortalSettingsCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count @@ -13922,32 +13804,33 @@ class PortalSettingsContract(Resource): from Azure API Management. :vartype validation_key: str :ivar subscriptions: Subscriptions delegation settings. - :vartype subscriptions: ~api_management_client.models.SubscriptionsDelegationSettingsProperties + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :ivar user_registration: User registration delegation settings. :vartype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~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: ~api_management_client.models.TermsOfServiceProperties + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -13955,10 +13838,10 @@ def __init__( *, url: Optional[str] = None, validation_key: Optional[str] = None, - subscriptions: Optional["SubscriptionsDelegationSettingsProperties"] = None, - user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, enabled: Optional[bool] = None, - terms_of_service: Optional["TermsOfServiceProperties"] = None, + terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, **kwargs ): """ @@ -13969,16 +13852,16 @@ def __init__( :paramtype validation_key: str :keyword subscriptions: Subscriptions delegation settings. :paramtype subscriptions: - ~api_management_client.models.SubscriptionsDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :keyword user_registration: User registration delegation settings. :paramtype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~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: ~api_management_client.models.TermsOfServiceProperties + :paramtype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ - super(PortalSettingsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.validation_key = validation_key self.subscriptions = subscriptions @@ -13987,7 +13870,7 @@ def __init__( self.terms_of_service = terms_of_service -class PortalSettingValidationKeyContract(msrest.serialization.Model): +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. @@ -13995,20 +13878,15 @@ class PortalSettingValidationKeyContract(msrest.serialization.Model): """ _attribute_map = { - 'validation_key': {'key': 'validationKey', 'type': 'str'}, + "validation_key": {"key": "validationKey", "type": "str"}, } - def __init__( - self, - *, - validation_key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, validation_key: Optional[str] = None, **kwargs): """ :keyword validation_key: This is secret value of the validation key in portal settings. :paramtype validation_key: str """ - super(PortalSettingValidationKeyContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.validation_key = validation_key @@ -14030,29 +13908,24 @@ class PortalSigninSettings(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Redirect Anonymous users to the Sign-In page. :paramtype enabled: bool """ - super(PortalSigninSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled @@ -14072,42 +13945,42 @@ class PortalSignupSettings(Resource): :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: ~api_management_client.models.TermsOfServiceProperties + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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["TermsOfServiceProperties"] = None, + terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, **kwargs ): """ :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: ~api_management_client.models.TermsOfServiceProperties + :paramtype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ - super(PortalSignupSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.terms_of_service = terms_of_service -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -14117,20 +13990,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -14148,137 +14017,140 @@ class PrivateEndpointConnection(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~api_management_client.models.PrivateEndpoint + :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: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or - ~api_management_client.models.PrivateEndpointConnectionProvisioningState + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~api_management_client.models.PrivateEndpoint + :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: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + 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(msrest.serialization.Model): +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[~api_management_client.models.PrivateEndpointConnection] + :vartype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. - :paramtype value: list[~api_management_client.models.PrivateEndpointConnection] + :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpointConnectionRequest(msrest.serialization.Model): +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: ~api_management_client.models.PrivateEndpointConnectionRequestProperties + :vartype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionRequestProperties'}, + "id": {"key": "id", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionRequestProperties"}, } def __init__( self, *, - id: Optional[str] = None, - properties: Optional["PrivateEndpointConnectionRequestProperties"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + properties: Optional["_models.PrivateEndpointConnectionRequestProperties"] = None, **kwargs ): """ :keyword id: Private Endpoint Connection Resource Id. :paramtype id: str :keyword properties: The connection state of the private endpoint connection. - :paramtype properties: ~api_management_client.models.PrivateEndpointConnectionRequestProperties + :paramtype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties """ - super(PrivateEndpointConnectionRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.properties = properties -class PrivateEndpointConnectionRequestProperties(msrest.serialization.Model): +class PrivateEndpointConnectionRequestProperties(_serialization.Model): """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: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ _attribute_map = { - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ :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: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionRequestProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_link_service_connection_state = private_link_service_connection_state @@ -14304,69 +14176,59 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "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]'}, + "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 - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. - :vartype value: list[~api_management_client.models.PrivateLinkResource] + :vartype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. - :paramtype value: list[~api_management_client.models.PrivateLinkResource] + :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +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. Possible values include: "Pending", "Approved", "Rejected". - :vartype status: str or ~api_management_client.models.PrivateEndpointServiceConnectionStatus + 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 @@ -14375,69 +14237,70 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, actions_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". - :paramtype status: str or ~api_management_client.models.PrivateEndpointServiceConnectionStatus + 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(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class ProductCollection(msrest.serialization.Model): +class ProductCollection(_serialization.Model): """Paged Products list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ProductContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ProductContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ProductContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ProductContract"]] = None, + value: Optional[List["_models.ProductContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.ProductContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.ProductContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(ProductCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -14480,31 +14343,31 @@ class ProductContract(Resource): :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. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + 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, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, + "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'}, + "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__( @@ -14515,7 +14378,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, display_name: Optional[str] = None, **kwargs ): @@ -14544,12 +14407,12 @@ def __init__( :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. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + 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(ProductContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.terms = terms self.subscription_required = subscription_required @@ -14559,7 +14422,7 @@ def __init__( self.display_name = display_name -class ProductEntityBaseParameters(msrest.serialization.Model): +class ProductEntityBaseParameters(_serialization.Model): """Product Entity Base Parameters. :ivar description: Product description. May include HTML formatting tags. @@ -14586,21 +14449,21 @@ class ProductEntityBaseParameters(msrest.serialization.Model): :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. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + of Product is notPublished. Known values are: "notPublished" and "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState """ _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, + "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'}, + "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__( @@ -14611,7 +14474,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, **kwargs ): """ @@ -14639,10 +14502,10 @@ def __init__( :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. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + state of Product is notPublished. Known values are: "notPublished" and "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState """ - super(ProductEntityBaseParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.terms = terms self.subscription_required = subscription_required @@ -14680,25 +14543,25 @@ class ProductContractProperties(ProductEntityBaseParameters): :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. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState - :ivar display_name: Required. Product name. + 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, 'min_length': 0}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + "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'}, + "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__( @@ -14710,7 +14573,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, **kwargs ): """ @@ -14738,12 +14601,20 @@ def __init__( :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. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState - :keyword display_name: Required. Product name. + 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(ProductContractProperties, self).__init__(description=description, terms=terms, subscription_required=subscription_required, approval_required=approval_required, subscriptions_limit=subscriptions_limit, state=state, **kwargs) + 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 @@ -14776,28 +14647,28 @@ class ProductTagResourceContractProperties(ProductEntityBaseParameters): :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. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + 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: Required. Product name. + :ivar name: Product name. Required. :vartype name: str """ _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'name': {'required': True, 'max_length': 300, 'min_length': 1}, + "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'}, + "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__( @@ -14809,8 +14680,8 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, - id: Optional[str] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ @@ -14838,19 +14709,27 @@ def __init__( :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. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + 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: Required. Product name. + :keyword name: Product name. Required. :paramtype name: str """ - super(ProductTagResourceContractProperties, self).__init__(description=description, terms=terms, subscription_required=subscription_required, approval_required=approval_required, subscriptions_limit=subscriptions_limit, state=state, **kwargs) + 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(msrest.serialization.Model): +class ProductUpdateParameters(_serialization.Model): """Product Update parameters. :ivar description: Product description. May include HTML formatting tags. @@ -14877,25 +14756,25 @@ class ProductUpdateParameters(msrest.serialization.Model): :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. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + 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, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, + "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'}, + "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__( @@ -14906,7 +14785,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, display_name: Optional[str] = None, **kwargs ): @@ -14935,12 +14814,12 @@ def __init__( :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. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + 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(ProductUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.terms = terms self.subscription_required = subscription_required @@ -14977,25 +14856,25 @@ class ProductUpdateProperties(ProductEntityBaseParameters): :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. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + 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, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, + "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'}, + "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__( @@ -15006,7 +14885,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, display_name: Optional[str] = None, **kwargs ): @@ -15035,87 +14914,95 @@ def __init__( :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. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + 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(ProductUpdateProperties, self).__init__(description=description, terms=terms, subscription_required=subscription_required, approval_required=approval_required, subscriptions_limit=subscriptions_limit, state=state, **kwargs) + 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(msrest.serialization.Model): +class QuotaCounterCollection(_serialization.Model): """Paged Quota Counter list representation. :ivar value: Quota counter values. - :vartype value: list[~api_management_client.models.QuotaCounterContract] + :vartype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[QuotaCounterContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["QuotaCounterContract"]] = None, + value: Optional[List["_models.QuotaCounterContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Quota counter values. - :paramtype value: list[~api_management_client.models.QuotaCounterContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(QuotaCounterCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class QuotaCounterContract(msrest.serialization.Model): +class QuotaCounterContract(_serialization.Model): """Quota counter details. All required parameters must be populated in order to send to Azure. - :ivar counter_key: Required. The Key value of the Counter. Must not be empty. + :ivar counter_key: The Key value of the Counter. Must not be empty. Required. :vartype counter_key: str - :ivar period_key: Required. Identifier of the Period for which the counter was collected. Must - not be empty. + :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: Required. 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. + :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: Required. 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. + :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: ~api_management_client.models.QuotaCounterValueContractProperties + :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}, + "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'}, + "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__( @@ -15125,26 +15012,25 @@ def __init__( period_key: str, period_start_time: datetime.datetime, period_end_time: datetime.datetime, - value: Optional["QuotaCounterValueContractProperties"] = None, + value: Optional["_models.QuotaCounterValueContractProperties"] = None, **kwargs ): """ - :keyword counter_key: Required. The Key value of the Counter. Must not be empty. + :keyword counter_key: The Key value of the Counter. Must not be empty. Required. :paramtype counter_key: str - :keyword period_key: Required. Identifier of the Period for which the counter was collected. - Must not be empty. + :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: Required. 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. + :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: Required. 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. + :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: ~api_management_client.models.QuotaCounterValueContractProperties + :paramtype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties """ - super(QuotaCounterContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.counter_key = counter_key self.period_key = period_key self.period_start_time = period_start_time @@ -15152,7 +15038,7 @@ def __init__( self.value = value -class QuotaCounterValueContract(msrest.serialization.Model): +class QuotaCounterValueContract(_serialization.Model): """Quota counter value details. :ivar calls_count: Number of times Counter was called. @@ -15162,29 +15048,23 @@ class QuotaCounterValueContract(msrest.serialization.Model): """ _attribute_map = { - 'calls_count': {'key': 'value.callsCount', 'type': 'int'}, - 'kb_transferred': {'key': 'value.kbTransferred', 'type': 'float'}, + "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 - ): + def __init__(self, *, calls_count: Optional[int] = None, kb_transferred: Optional[float] = None, **kwargs): """ :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(QuotaCounterValueContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.calls_count = calls_count self.kb_transferred = kb_transferred -class QuotaCounterValueContractProperties(msrest.serialization.Model): +class QuotaCounterValueContractProperties(_serialization.Model): """Quota counter value details. :ivar calls_count: Number of times Counter was called. @@ -15194,29 +15074,23 @@ class QuotaCounterValueContractProperties(msrest.serialization.Model): """ _attribute_map = { - 'calls_count': {'key': 'callsCount', 'type': 'int'}, - 'kb_transferred': {'key': 'kbTransferred', 'type': 'float'}, + "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 - ): + def __init__(self, *, calls_count: Optional[int] = None, kb_transferred: Optional[float] = None, **kwargs): """ :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(QuotaCounterValueContractProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.calls_count = calls_count self.kb_transferred = kb_transferred -class QuotaCounterValueUpdateContract(msrest.serialization.Model): +class QuotaCounterValueUpdateContract(_serialization.Model): """Quota counter value details. :ivar calls_count: Number of times Counter was called. @@ -15226,62 +15100,56 @@ class QuotaCounterValueUpdateContract(msrest.serialization.Model): """ _attribute_map = { - 'calls_count': {'key': 'properties.callsCount', 'type': 'int'}, - 'kb_transferred': {'key': 'properties.kbTransferred', 'type': 'float'}, + "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 - ): + def __init__(self, *, calls_count: Optional[int] = None, kb_transferred: Optional[float] = None, **kwargs): """ :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(QuotaCounterValueUpdateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.calls_count = calls_count self.kb_transferred = kb_transferred -class RecipientEmailCollection(msrest.serialization.Model): +class RecipientEmailCollection(_serialization.Model): """Paged Recipient User list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.RecipientEmailContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RecipientEmailContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["RecipientEmailContract"]] = None, + value: Optional[List["_models.RecipientEmailContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.RecipientEmailContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(RecipientEmailCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -15305,33 +15173,28 @@ class RecipientEmailContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, *, email: Optional[str] = None, **kwargs): """ :keyword email: User Email subscribed to notification. :paramtype email: str """ - super(RecipientEmailContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.email = email -class RecipientsContractProperties(msrest.serialization.Model): +class RecipientsContractProperties(_serialization.Model): """Notification Parameter contract. :ivar emails: List of Emails subscribed for the notification. @@ -15341,62 +15204,56 @@ class RecipientsContractProperties(msrest.serialization.Model): """ _attribute_map = { - 'emails': {'key': 'emails', 'type': '[str]'}, - 'users': {'key': 'users', 'type': '[str]'}, + "emails": {"key": "emails", "type": "[str]"}, + "users": {"key": "users", "type": "[str]"}, } - def __init__( - self, - *, - emails: Optional[List[str]] = None, - users: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, emails: Optional[List[str]] = None, users: Optional[List[str]] = None, **kwargs): """ :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(RecipientsContractProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.emails = emails self.users = users -class RecipientUserCollection(msrest.serialization.Model): +class RecipientUserCollection(_serialization.Model): """Paged Recipient User list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.RecipientUserContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RecipientUserContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["RecipientUserContract"]] = None, + value: Optional[List["_models.RecipientUserContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.RecipientUserContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(RecipientUserCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -15420,33 +15277,28 @@ class RecipientUserContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, *, user_id: Optional[str] = None, **kwargs): """ :keyword user_id: API Management UserId subscribed to notification. :paramtype user_id: str """ - super(RecipientUserContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_id = user_id -class RegionContract(msrest.serialization.Model): +class RegionContract(_serialization.Model): """Region profile. Variables are only populated by the server, and will be ignored when sending a request. @@ -15460,74 +15312,68 @@ class RegionContract(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_master_region': {'key': 'isMasterRegion', 'type': 'bool'}, - 'is_deleted': {'key': 'isDeleted', 'type': 'bool'}, + "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 - ): + def __init__(self, *, is_master_region: Optional[bool] = None, is_deleted: Optional[bool] = None, **kwargs): """ :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(RegionContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.is_master_region = is_master_region self.is_deleted = is_deleted -class RegionListResult(msrest.serialization.Model): +class RegionListResult(_serialization.Model): """Lists Regions operation response details. :ivar value: Lists of Regions. - :vartype value: list[~api_management_client.models.RegionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RegionContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RegionContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["RegionContract"]] = None, + value: Optional[List["_models.RegionContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Lists of Regions. - :paramtype value: list[~api_management_client.models.RegionContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RegionContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(RegionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class RegistrationDelegationSettingsProperties(msrest.serialization.Model): +class RegistrationDelegationSettingsProperties(_serialization.Model): """User registration delegation settings properties. :ivar enabled: Enable or disable delegation for user registration. @@ -15535,24 +15381,19 @@ class RegistrationDelegationSettingsProperties(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Enable or disable delegation for user registration. :paramtype enabled: bool """ - super(RegistrationDelegationSettingsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class RemotePrivateEndpointConnectionWrapper(msrest.serialization.Model): +class RemotePrivateEndpointConnectionWrapper(_serialization.Model): """Remote Private Endpoint Connection resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -15564,11 +15405,11 @@ class RemotePrivateEndpointConnectionWrapper(msrest.serialization.Model): :ivar type: Private Endpoint Connection Resource Type. :vartype type: str :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~api_management_client.models.ArmIdWrapper + :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: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~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. @@ -15576,28 +15417,31 @@ class RemotePrivateEndpointConnectionWrapper(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'group_ids': {'readonly': True}, + "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]'}, + "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, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, - private_endpoint: Optional["ArmIdWrapper"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.ArmIdWrapper"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -15608,13 +15452,13 @@ def __init__( :keyword type: Private Endpoint Connection Resource Type. :paramtype type: str :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~api_management_client.models.ArmIdWrapper + :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: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ - super(RemotePrivateEndpointConnectionWrapper, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -15624,46 +15468,46 @@ def __init__( self.group_ids = None -class ReportCollection(msrest.serialization.Model): +class ReportCollection(_serialization.Model): """Paged Report records list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ReportRecordContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ReportRecordContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ReportRecordContract"]] = None, + value: Optional[List["_models.ReportRecordContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.ReportRecordContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(ReportCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class ReportRecordContract(msrest.serialization.Model): +class ReportRecordContract(_serialization.Model): # pylint: disable=too-many-instance-attributes """Report data. Variables are only populated by the server, and will be ignored when sending a request. @@ -15712,7 +15556,7 @@ class ReportRecordContract(msrest.serialization.Model): :ivar call_count_total: Total number of calls. :vartype call_count_total: int :ivar bandwidth: Bandwidth consumed. - :vartype bandwidth: long + :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. @@ -15732,40 +15576,40 @@ class ReportRecordContract(msrest.serialization.Model): """ _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': 'long'}, - '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__( + "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, @@ -15835,7 +15679,7 @@ def __init__( :keyword call_count_total: Total number of calls. :paramtype call_count_total: int :keyword bandwidth: Bandwidth consumed. - :paramtype bandwidth: long + :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. @@ -15853,7 +15697,7 @@ def __init__( :keyword service_time_max: Maximum time it took to process request on backend. :paramtype service_time_max: float """ - super(ReportRecordContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.timestamp = timestamp self.interval = interval @@ -15882,13 +15726,13 @@ def __init__( self.service_time_max = service_time_max -class RepresentationContract(msrest.serialization.Model): +class RepresentationContract(_serialization.Model): """Operation request/response representation details. All required parameters must be populated in order to send to Azure. - :ivar content_type: Required. Specifies a registered or custom content type for this - representation, e.g. application/xml. + :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'. @@ -15898,21 +15742,21 @@ class RepresentationContract(msrest.serialization.Model): :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[~api_management_client.models.ParameterContract] + :vartype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar examples: Exampled defined for the representation. - :vartype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ _validation = { - 'content_type': {'required': True}, + "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}'}, + "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__( @@ -15921,13 +15765,13 @@ def __init__( content_type: str, schema_id: Optional[str] = None, type_name: Optional[str] = None, - form_parameters: Optional[List["ParameterContract"]] = None, - examples: Optional[Dict[str, "ParameterExampleContract"]] = None, + form_parameters: Optional[List["_models.ParameterContract"]] = None, + examples: Optional[Dict[str, "_models.ParameterExampleContract"]] = None, **kwargs ): """ - :keyword content_type: Required. Specifies a registered or custom content type for this - representation, e.g. application/xml. + :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'. @@ -15937,11 +15781,11 @@ def __init__( :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[~api_management_client.models.ParameterContract] + :paramtype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword examples: Exampled defined for the representation. - :paramtype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ - super(RepresentationContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.content_type = content_type self.schema_id = schema_id self.type_name = type_name @@ -15949,85 +15793,85 @@ def __init__( self.examples = examples -class RequestContract(msrest.serialization.Model): +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[~api_management_client.models.ParameterContract] + :vartype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar headers: Collection of operation request headers. - :vartype headers: list[~api_management_client.models.ParameterContract] + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar representations: Collection of operation request representations. - :vartype representations: list[~api_management_client.models.RepresentationContract] + :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]'}, + "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["ParameterContract"]] = None, - headers: Optional[List["ParameterContract"]] = None, - representations: Optional[List["RepresentationContract"]] = None, + query_parameters: Optional[List["_models.ParameterContract"]] = None, + headers: Optional[List["_models.ParameterContract"]] = None, + representations: Optional[List["_models.RepresentationContract"]] = None, **kwargs ): """ :keyword description: Operation request description. :paramtype description: str :keyword query_parameters: Collection of operation request query parameters. - :paramtype query_parameters: list[~api_management_client.models.ParameterContract] + :paramtype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword headers: Collection of operation request headers. - :paramtype headers: list[~api_management_client.models.ParameterContract] + :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword representations: Collection of operation request representations. - :paramtype representations: list[~api_management_client.models.RepresentationContract] + :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] """ - super(RequestContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.query_parameters = query_parameters self.headers = headers self.representations = representations -class RequestReportCollection(msrest.serialization.Model): +class RequestReportCollection(_serialization.Model): """Paged Report records list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.RequestReportRecordContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] :ivar count: Total record count number across all pages. - :vartype count: long + :vartype count: int """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RequestReportRecordContract]'}, - 'count': {'key': 'count', 'type': 'long'}, + "value": {"key": "value", "type": "[RequestReportRecordContract]"}, + "count": {"key": "count", "type": "int"}, } def __init__( self, *, - value: Optional[List["RequestReportRecordContract"]] = None, + value: Optional[List["_models.RequestReportRecordContract"]] = None, count: Optional[int] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.RequestReportRecordContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int """ - super(RequestReportCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count -class RequestReportRecordContract(msrest.serialization.Model): +class RequestReportRecordContract(_serialization.Model): # pylint: disable=too-many-instance-attributes """Request Report data. Variables are only populated by the server, and will be ignored when sending a request. @@ -16077,29 +15921,29 @@ class RequestReportRecordContract(msrest.serialization.Model): """ _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'}, + "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__( @@ -16163,7 +16007,7 @@ def __init__( :keyword request_size: The size of this request.. :paramtype request_size: int """ - super(RequestReportRecordContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.api_id = api_id self.operation_id = operation_id self.product_id = None @@ -16184,12 +16028,12 @@ def __init__( self.request_size = request_size -class ResourceLocationDataContract(msrest.serialization.Model): +class ResourceLocationDataContract(_serialization.Model): """Resource location data properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. A canonical name for the geographic or physical location. + :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 @@ -16200,17 +16044,17 @@ class ResourceLocationDataContract(msrest.serialization.Model): """ _validation = { - 'name': {'required': True, 'max_length': 256, 'min_length': 0}, - 'city': {'max_length': 256, 'min_length': 0}, - 'district': {'max_length': 256, 'min_length': 0}, - 'country_or_region': {'max_length': 256, 'min_length': 0}, + "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'}, + "name": {"key": "name", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "district": {"key": "district", "type": "str"}, + "country_or_region": {"key": "countryOrRegion", "type": "str"}, } def __init__( @@ -16223,7 +16067,7 @@ def __init__( **kwargs ): """ - :keyword name: Required. A canonical name for the geographic or physical location. + :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 @@ -16232,41 +16076,36 @@ def __init__( :keyword country_or_region: The country or region where the resource is located. :paramtype country_or_region: str """ - super(ResourceLocationDataContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.city = city self.district = district self.country_or_region = country_or_region -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """Describes an available API Management SKU. - :ivar name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", - "Basic", "Consumption", "Isolated". - :vartype name: str or ~api_management_client.models.SkuType + :ivar name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", + "Consumption", and "Isolated". + :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[Union[str, "SkuType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[Union[str, "_models.SkuType"]] = None, **kwargs): """ - :keyword name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", - "Basic", "Consumption", "Isolated". - :paramtype name: str or ~api_management_client.models.SkuType + :keyword name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", + "Consumption", and "Isolated". + :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ResourceSkuCapacity(msrest.serialization.Model): +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. @@ -16277,39 +16116,35 @@ class ResourceSkuCapacity(msrest.serialization.Model): :vartype maximum: int :ivar default: The default capacity. :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values include: "automatic", - "manual", "none". - :vartype scale_type: str or ~api_management_client.models.ResourceSkuCapacityScaleType + :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}, + "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'}, + "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 - ): - """ - """ - super(ResourceSkuCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None self.scale_type = None -class ResourceSkuResult(msrest.serialization.Model): +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. @@ -16317,97 +16152,87 @@ class ResourceSkuResult(msrest.serialization.Model): :ivar resource_type: The type of resource the SKU applies to. :vartype resource_type: str :ivar sku: Specifies API Management SKU. - :vartype sku: ~api_management_client.models.ResourceSku + :vartype sku: ~azure.mgmt.apimanagement.models.ResourceSku :ivar capacity: Specifies the number of API Management units. - :vartype capacity: ~api_management_client.models.ResourceSkuCapacity + :vartype capacity: ~azure.mgmt.apimanagement.models.ResourceSkuCapacity """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'readonly': True}, - 'capacity': {'readonly': True}, + "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'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "ResourceSku"}, + "capacity": {"key": "capacity", "type": "ResourceSkuCapacity"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceSkuResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.sku = None self.capacity = None -class ResourceSkuResults(msrest.serialization.Model): +class ResourceSkuResults(_serialization.Model): """The API Management service SKUs operation response. All required parameters must be populated in order to send to Azure. - :ivar value: Required. The list of skus available for the service. - :vartype value: list[~api_management_client.models.ResourceSkuResult] + :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}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSkuResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceSkuResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["ResourceSkuResult"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.ResourceSkuResult"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. The list of skus available for the service. - :paramtype value: list[~api_management_client.models.ResourceSkuResult] + :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(ResourceSkuResults, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResponseContract(msrest.serialization.Model): +class ResponseContract(_serialization.Model): """Operation response details. All required parameters must be populated in order to send to Azure. - :ivar status_code: Required. Operation response HTTP status code. + :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[~api_management_client.models.RepresentationContract] + :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] :ivar headers: Collection of operation response headers. - :vartype headers: list[~api_management_client.models.ParameterContract] + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] """ _validation = { - 'status_code': {'required': True}, + "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]'}, + "status_code": {"key": "statusCode", "type": "int"}, + "description": {"key": "description", "type": "str"}, + "representations": {"key": "representations", "type": "[RepresentationContract]"}, + "headers": {"key": "headers", "type": "[ParameterContract]"}, } def __init__( @@ -16415,64 +16240,64 @@ def __init__( *, status_code: int, description: Optional[str] = None, - representations: Optional[List["RepresentationContract"]] = None, - headers: Optional[List["ParameterContract"]] = None, + representations: Optional[List["_models.RepresentationContract"]] = None, + headers: Optional[List["_models.ParameterContract"]] = None, **kwargs ): """ - :keyword status_code: Required. Operation response HTTP status code. + :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[~api_management_client.models.RepresentationContract] + :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] :keyword headers: Collection of operation response headers. - :paramtype headers: list[~api_management_client.models.ParameterContract] + :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] """ - super(ResponseContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.status_code = status_code self.description = description self.representations = representations self.headers = headers -class SamplingSettings(msrest.serialization.Model): +class SamplingSettings(_serialization.Model): """Sampling settings for Diagnostic. - :ivar sampling_type: Sampling type. Possible values include: "fixed". - :vartype sampling_type: str or ~api_management_client.models.SamplingType + :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}, + "percentage": {"maximum": 100, "minimum": 0}, } _attribute_map = { - 'sampling_type': {'key': 'samplingType', 'type': 'str'}, - 'percentage': {'key': 'percentage', 'type': 'float'}, + "sampling_type": {"key": "samplingType", "type": "str"}, + "percentage": {"key": "percentage", "type": "float"}, } def __init__( self, *, - sampling_type: Optional[Union[str, "SamplingType"]] = None, + sampling_type: Optional[Union[str, "_models.SamplingType"]] = None, percentage: Optional[float] = None, **kwargs ): """ - :keyword sampling_type: Sampling type. Possible values include: "fixed". - :paramtype sampling_type: str or ~api_management_client.models.SamplingType + :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(SamplingSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.sampling_type = sampling_type self.percentage = percentage -class SaveConfigurationParameter(msrest.serialization.Model): +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. @@ -16483,17 +16308,11 @@ class SaveConfigurationParameter(msrest.serialization.Model): """ _attribute_map = { - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'force': {'key': 'properties.force', 'type': 'bool'}, + "branch": {"key": "properties.branch", "type": "str"}, + "force": {"key": "properties.force", "type": "bool"}, } - def __init__( - self, - *, - branch: Optional[str] = None, - force: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, branch: Optional[str] = None, force: Optional[bool] = None, **kwargs): """ :keyword branch: The name of the Git branch in which to commit the current configuration snapshot. @@ -16502,46 +16321,41 @@ def __init__( repository, even if the Git repository has newer changes that would be overwritten. :paramtype force: bool """ - super(SaveConfigurationParameter, self).__init__(**kwargs) + super().__init__(**kwargs) self.branch = branch self.force = force -class SchemaCollection(msrest.serialization.Model): +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[~api_management_client.models.SchemaContract] + :vartype value: list[~azure.mgmt.apimanagement.models.SchemaContract] :ivar count: Total record count number. - :vartype count: long + :vartype count: int :ivar next_link: Next page link if any. :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SchemaContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SchemaContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: Total record count number. - :paramtype count: long + :paramtype count: int """ - super(SchemaCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = None self.count = count self.next_link = None @@ -16571,26 +16385,26 @@ class SchemaContract(Resource): schemas other than Swagger/OpenAPI. :vartype value: str :ivar definitions: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise. - :vartype definitions: any + :vartype definitions: JSON :ivar components: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null otherwise. - :vartype components: any + :vartype components: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, - 'content_type': {'key': 'properties.contentType', 'type': 'str'}, - 'value': {'key': 'properties.document.value', 'type': 'str'}, - 'definitions': {'key': 'properties.document.definitions', 'type': 'object'}, - 'components': {'key': 'properties.document.components', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "content_type": {"key": "properties.contentType", "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__( @@ -16598,8 +16412,8 @@ def __init__( *, content_type: Optional[str] = None, value: Optional[str] = None, - definitions: Optional[Any] = None, - components: Optional[Any] = None, + definitions: Optional[JSON] = None, + components: Optional[JSON] = None, **kwargs ): """ @@ -16615,58 +16429,58 @@ def __init__( :paramtype value: str :keyword definitions: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise. - :paramtype definitions: any + :paramtype definitions: JSON :keyword components: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null otherwise. - :paramtype components: any + :paramtype components: JSON """ - super(SchemaContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.content_type = content_type self.value = value self.definitions = definitions self.components = components -class SubscriptionCollection(msrest.serialization.Model): +class SubscriptionCollection(_serialization.Model): """Paged Subscriptions list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.SubscriptionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SubscriptionContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SubscriptionContract"]] = None, + value: Optional[List["_models.SubscriptionContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.SubscriptionContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(SubscriptionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class SubscriptionContract(Resource): +class SubscriptionContract(Resource): # pylint: disable=too-many-instance-attributes """Subscription details. Variables are only populated by the server, and will be ignored when sending a request. @@ -16692,9 +16506,8 @@ class SubscriptionContract(Resource): 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. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :vartype state: str or ~api_management_client.models.SubscriptionState + 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 @@ -16730,32 +16543,32 @@ class SubscriptionContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 100, 'min_length': 0}, - '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'}, + "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__( @@ -16764,7 +16577,7 @@ def __init__( owner_id: Optional[str] = None, scope: Optional[str] = None, display_name: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = 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, @@ -16789,9 +16602,8 @@ def __init__( 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. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :paramtype state: str or ~api_management_client.models.SubscriptionState + 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: @@ -16823,7 +16635,7 @@ def __init__( :keyword allow_tracing: Determines whether tracing is enabled. :paramtype allow_tracing: bool """ - super(SubscriptionContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.owner_id = owner_id self.scope = scope self.display_name = display_name @@ -16839,7 +16651,7 @@ def __init__( self.allow_tracing = allow_tracing -class SubscriptionCreateParameters(msrest.serialization.Model): +class SubscriptionCreateParameters(_serialization.Model): """Subscription create details. :ivar owner_id: User (user id path) for whom subscription is being created in form @@ -16861,27 +16673,27 @@ class SubscriptionCreateParameters(msrest.serialization.Model): 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. Possible values include: - "suspended", "active", "expired", "submitted", "rejected", "cancelled". - :vartype state: str or ~api_management_client.models.SubscriptionState + 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}, + "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'}, + "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__( @@ -16892,7 +16704,7 @@ def __init__( display_name: Optional[str] = None, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + state: Optional[Union[str, "_models.SubscriptionState"]] = None, allow_tracing: Optional[bool] = None, **kwargs ): @@ -16917,13 +16729,12 @@ def __init__( 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. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :paramtype state: str or ~api_management_client.models.SubscriptionState + 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(SubscriptionCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.owner_id = owner_id self.scope = scope self.display_name = display_name @@ -16933,7 +16744,7 @@ def __init__( self.allow_tracing = allow_tracing -class SubscriptionKeyParameterNamesContract(msrest.serialization.Model): +class SubscriptionKeyParameterNamesContract(_serialization.Model): """Subscription key parameter names details. :ivar header: Subscription key header name. @@ -16943,29 +16754,23 @@ class SubscriptionKeyParameterNamesContract(msrest.serialization.Model): """ _attribute_map = { - 'header': {'key': 'header', 'type': 'str'}, - 'query': {'key': 'query', 'type': 'str'}, + "header": {"key": "header", "type": "str"}, + "query": {"key": "query", "type": "str"}, } - def __init__( - self, - *, - header: Optional[str] = None, - query: Optional[str] = None, - **kwargs - ): + def __init__(self, *, header: Optional[str] = None, query: Optional[str] = None, **kwargs): """ :keyword header: Subscription key header name. :paramtype header: str :keyword query: Subscription key query string parameter name. :paramtype query: str """ - super(SubscriptionKeyParameterNamesContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.header = header self.query = query -class SubscriptionKeysContract(msrest.serialization.Model): +class SubscriptionKeysContract(_serialization.Model): """Subscription keys. :ivar primary_key: Subscription primary key. @@ -16975,34 +16780,28 @@ class SubscriptionKeysContract(msrest.serialization.Model): """ _validation = { - 'primary_key': {'max_length': 256, 'min_length': 1}, - 'secondary_key': {'max_length': 256, 'min_length': 1}, + "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'}, + "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 - ): + def __init__(self, *, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs): """ :keyword primary_key: Subscription primary key. :paramtype primary_key: str :keyword secondary_key: Subscription secondary key. :paramtype secondary_key: str """ - super(SubscriptionKeysContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key -class SubscriptionsDelegationSettingsProperties(msrest.serialization.Model): +class SubscriptionsDelegationSettingsProperties(_serialization.Model): """Subscriptions delegation settings properties. :ivar enabled: Enable or disable delegation for subscriptions. @@ -17010,24 +16809,19 @@ class SubscriptionsDelegationSettingsProperties(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Enable or disable delegation for subscriptions. :paramtype enabled: bool """ - super(SubscriptionsDelegationSettingsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class SubscriptionUpdateParameters(msrest.serialization.Model): +class SubscriptionUpdateParameters(_serialization.Model): """Subscription update details. :ivar owner_id: User identifier path: /users/{userId}. @@ -17051,9 +16845,8 @@ class SubscriptionUpdateParameters(msrest.serialization.Model): 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. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :vartype state: str or ~api_management_client.models.SubscriptionState + 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 @@ -17062,20 +16855,20 @@ class SubscriptionUpdateParameters(msrest.serialization.Model): """ _validation = { - 'primary_key': {'max_length': 256, 'min_length': 1}, - 'secondary_key': {'max_length': 256, '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'}, - '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'}, + "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__( @@ -17087,7 +16880,7 @@ def __init__( display_name: Optional[str] = None, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + state: Optional[Union[str, "_models.SubscriptionState"]] = None, state_comment: Optional[str] = None, allow_tracing: Optional[bool] = None, **kwargs @@ -17114,16 +16907,15 @@ def __init__( 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. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :paramtype state: str or ~api_management_client.models.SubscriptionState + 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(SubscriptionUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.owner_id = owner_id self.scope = scope self.expiration_date = expiration_date @@ -17135,62 +16927,62 @@ def __init__( self.allow_tracing = allow_tracing -class SystemData(msrest.serialization.Model): +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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". - :vartype created_by_type: str or ~api_management_client.models.CreatedByType + :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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :vartype last_modified_by_type: str or ~api_management_client.models.CreatedByType + :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'}, + "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, "CreatedByType"]] = 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, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :paramtype created_by_type: str or ~api_management_client.models.CreatedByType + :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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :paramtype last_modified_by_type: str or ~api_management_client.models.CreatedByType + :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(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -17199,40 +16991,40 @@ def __init__( self.last_modified_at = last_modified_at -class TagCollection(msrest.serialization.Model): +class TagCollection(_serialization.Model): """Paged Tag list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.TagContract] + :vartype value: list[~azure.mgmt.apimanagement.models.TagContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["TagContract"]] = None, + value: Optional[List["_models.TagContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.TagContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.TagContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(TagCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -17256,34 +17048,29 @@ class TagContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 160, 'min_length': 1}, + "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'}, + "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 - ): + def __init__(self, *, display_name: Optional[str] = None, **kwargs): """ :keyword display_name: Tag name. :paramtype display_name: str """ - super(TagContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name -class TagCreateUpdateParameters(msrest.serialization.Model): +class TagCreateUpdateParameters(_serialization.Model): """Parameters supplied to Create/Update Tag operations. :ivar display_name: Tag name. @@ -17291,28 +17078,23 @@ class TagCreateUpdateParameters(msrest.serialization.Model): """ _validation = { - 'display_name': {'max_length': 160, 'min_length': 1}, + "display_name": {"max_length": 160, "min_length": 1}, } _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + "display_name": {"key": "properties.displayName", "type": "str"}, } - def __init__( - self, - *, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, display_name: Optional[str] = None, **kwargs): """ :keyword display_name: Tag name. :paramtype display_name: str """ - super(TagCreateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name -class TagDescriptionBaseProperties(msrest.serialization.Model): +class TagDescriptionBaseProperties(_serialization.Model): """Parameters supplied to the Create TagDescription operation. :ivar description: Description of the Tag. @@ -17324,13 +17106,13 @@ class TagDescriptionBaseProperties(msrest.serialization.Model): """ _validation = { - 'external_docs_url': {'max_length': 2000, 'min_length': 0}, + "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'}, + "description": {"key": "description", "type": "str"}, + "external_docs_url": {"key": "externalDocsUrl", "type": "str"}, + "external_docs_description": {"key": "externalDocsDescription", "type": "str"}, } def __init__( @@ -17349,46 +17131,46 @@ def __init__( :keyword external_docs_description: Description of the external resources describing the tag. :paramtype external_docs_description: str """ - super(TagDescriptionBaseProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url self.external_docs_description = external_docs_description -class TagDescriptionCollection(msrest.serialization.Model): +class TagDescriptionCollection(_serialization.Model): """Paged TagDescription list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.TagDescriptionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDescriptionContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["TagDescriptionContract"]] = None, + value: Optional[List["_models.TagDescriptionContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.TagDescriptionContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(TagDescriptionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link @@ -17420,22 +17202,22 @@ class TagDescriptionContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'external_docs_url': {'max_length': 2000, 'min_length': 0}, - 'display_name': {'max_length': 160, 'min_length': 1}, + "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'}, + "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__( @@ -17460,7 +17242,7 @@ def __init__( :keyword display_name: Tag name. :paramtype display_name: str """ - super(TagDescriptionContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url self.external_docs_description = external_docs_description @@ -17484,16 +17266,16 @@ class TagDescriptionContractProperties(TagDescriptionBaseProperties): """ _validation = { - 'external_docs_url': {'max_length': 2000, 'min_length': 0}, - 'display_name': {'max_length': 160, 'min_length': 1}, + "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'}, + "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__( @@ -17518,12 +17300,17 @@ def __init__( :keyword display_name: Tag name. :paramtype display_name: str """ - super(TagDescriptionContractProperties, self).__init__(description=description, external_docs_url=external_docs_url, external_docs_description=external_docs_description, **kwargs) + 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(msrest.serialization.Model): +class TagDescriptionCreateParameters(_serialization.Model): """Parameters supplied to the Create TagDescription operation. :ivar description: Description of the Tag. @@ -17535,13 +17322,13 @@ class TagDescriptionCreateParameters(msrest.serialization.Model): """ _validation = { - 'external_docs_url': {'max_length': 2000, 'min_length': 0}, + "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'}, + "description": {"key": "properties.description", "type": "str"}, + "external_docs_url": {"key": "properties.externalDocsUrl", "type": "str"}, + "external_docs_description": {"key": "properties.externalDocsDescription", "type": "str"}, } def __init__( @@ -17560,104 +17347,104 @@ def __init__( :keyword external_docs_description: Description of the external resources describing the tag. :paramtype external_docs_description: str """ - super(TagDescriptionCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url self.external_docs_description = external_docs_description -class TagResourceCollection(msrest.serialization.Model): +class TagResourceCollection(_serialization.Model): """Paged Tag list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.TagResourceContract] + :vartype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagResourceContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["TagResourceContract"]] = None, + value: Optional[List["_models.TagResourceContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.TagResourceContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(TagResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class TagResourceContract(msrest.serialization.Model): +class TagResourceContract(_serialization.Model): """TagResource contract properties. All required parameters must be populated in order to send to Azure. - :ivar tag: Required. Tag associated with the resource. - :vartype tag: ~api_management_client.models.TagResourceContractProperties + :ivar tag: Tag associated with the resource. Required. + :vartype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties :ivar api: API associated with the tag. - :vartype api: ~api_management_client.models.ApiTagResourceContractProperties + :vartype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties :ivar operation: Operation associated with the tag. - :vartype operation: ~api_management_client.models.OperationTagResourceContractProperties + :vartype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties :ivar product: Product associated with the tag. - :vartype product: ~api_management_client.models.ProductTagResourceContractProperties + :vartype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties """ _validation = { - 'tag': {'required': True}, + "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'}, + "tag": {"key": "tag", "type": "TagResourceContractProperties"}, + "api": {"key": "api", "type": "ApiTagResourceContractProperties"}, + "operation": {"key": "operation", "type": "OperationTagResourceContractProperties"}, + "product": {"key": "product", "type": "ProductTagResourceContractProperties"}, } def __init__( self, *, - tag: "TagResourceContractProperties", - api: Optional["ApiTagResourceContractProperties"] = None, - operation: Optional["OperationTagResourceContractProperties"] = None, - product: Optional["ProductTagResourceContractProperties"] = None, + tag: "_models.TagResourceContractProperties", + api: Optional["_models.ApiTagResourceContractProperties"] = None, + operation: Optional["_models.OperationTagResourceContractProperties"] = None, + product: Optional["_models.ProductTagResourceContractProperties"] = None, **kwargs ): """ - :keyword tag: Required. Tag associated with the resource. - :paramtype tag: ~api_management_client.models.TagResourceContractProperties + :keyword tag: Tag associated with the resource. Required. + :paramtype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties :keyword api: API associated with the tag. - :paramtype api: ~api_management_client.models.ApiTagResourceContractProperties + :paramtype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties :keyword operation: Operation associated with the tag. - :paramtype operation: ~api_management_client.models.OperationTagResourceContractProperties + :paramtype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties :keyword product: Product associated with the tag. - :paramtype product: ~api_management_client.models.ProductTagResourceContractProperties + :paramtype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties """ - super(TagResourceContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag = tag self.api = api self.operation = operation self.product = product -class TagResourceContractProperties(msrest.serialization.Model): +class TagResourceContractProperties(_serialization.Model): """Contract defining the Tag property in the Tag Resource Contract. :ivar id: Tag identifier. @@ -17667,20 +17454,16 @@ class TagResourceContractProperties(msrest.serialization.Model): """ _validation = { - 'name': {'max_length': 160, 'min_length': 1}, + "name": {"max_length": 160, "min_length": 1}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( - self, - *, - id: Optional[str] = None, - name: Optional[str] = None, - **kwargs + self, *, id: Optional[str] = None, name: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin ): """ :keyword id: Tag identifier. @@ -17688,12 +17471,12 @@ def __init__( :keyword name: Tag Name. :paramtype name: str """ - super(TagResourceContractProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name -class TenantConfigurationSyncStateContract(Resource): +class TenantConfigurationSyncStateContract(Resource): # pylint: disable=too-many-instance-attributes """Result of Tenant Configuration Sync State. Variables are only populated by the server, and will be ignored when sending a request. @@ -17728,23 +17511,23 @@ class TenantConfigurationSyncStateContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -17782,7 +17565,7 @@ def __init__( :keyword last_operation_id: Most recent tenant configuration operation identifier. :paramtype last_operation_id: str """ - super(TenantConfigurationSyncStateContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.branch = branch self.commit_id = commit_id self.is_export = is_export @@ -17793,34 +17576,30 @@ def __init__( self.last_operation_id = last_operation_id -class TenantSettingsCollection(msrest.serialization.Model): +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[~api_management_client.models.TenantSettingsContract] + :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}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantSettingsContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TenantSettingsContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TenantSettingsCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -17843,33 +17622,28 @@ class TenantSettingsContract(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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 - ): + def __init__(self, *, settings: Optional[Dict[str, str]] = None, **kwargs): """ :keyword settings: Tenant settings. :paramtype settings: dict[str, str] """ - super(TenantSettingsContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.settings = settings -class TermsOfServiceProperties(msrest.serialization.Model): +class TermsOfServiceProperties(_serialization.Model): """Terms of service contract properties. :ivar text: A terms of service text. @@ -17881,9 +17655,9 @@ class TermsOfServiceProperties(msrest.serialization.Model): """ _attribute_map = { - 'text': {'key': 'text', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'consent_required': {'key': 'consentRequired', 'type': 'bool'}, + "text": {"key": "text", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "consent_required": {"key": "consentRequired", "type": "bool"}, } def __init__( @@ -17902,91 +17676,85 @@ def __init__( :keyword consent_required: Ask user for consent to the terms of service. :paramtype consent_required: bool """ - super(TermsOfServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.text = text self.enabled = enabled self.consent_required = consent_required -class TokenBodyParameterContract(msrest.serialization.Model): +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 Azure. - :ivar name: Required. body parameter name. + :ivar name: body parameter name. Required. :vartype name: str - :ivar value: Required. body parameter value. + :ivar value: body parameter value. Required. :vartype value: str """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, value: str, **kwargs): """ - :keyword name: Required. body parameter name. + :keyword name: body parameter name. Required. :paramtype name: str - :keyword value: Required. body parameter value. + :keyword value: body parameter value. Required. :paramtype value: str """ - super(TokenBodyParameterContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class UserCollection(msrest.serialization.Model): +class UserCollection(_serialization.Model): """Paged Users list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.UserContract] + :vartype value: list[~azure.mgmt.apimanagement.models.UserContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["UserContract"]] = None, + value: Optional[List["_models.UserContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.UserContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.UserContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(UserCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class UserContract(Resource): +class UserContract(Resource): # pylint: disable=too-many-instance-attributes """User details. Variables are only populated by the server, and will be ignored when sending a request. @@ -18001,13 +17769,12 @@ class UserContract(Resource): :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :vartype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar first_name: First name. :vartype first_name: str :ivar last_name: Last name. @@ -18018,36 +17785,36 @@ class UserContract(Resource): ``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[~api_management_client.models.GroupContractProperties] + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'groups': {'readonly': True}, + "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]'}, + "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: Optional[Union[str, "UserState"]] = "active", + state: Union[str, "_models.UserState"] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, first_name: Optional[str] = None, last_name: Optional[str] = None, email: Optional[str] = None, @@ -18057,13 +17824,12 @@ def __init__( """ :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :paramtype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword first_name: First name. :paramtype first_name: str :keyword last_name: Last name. @@ -18074,7 +17840,7 @@ def __init__( format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :paramtype registration_date: ~datetime.datetime """ - super(UserContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.note = note self.identities = identities @@ -18085,46 +17851,44 @@ def __init__( self.groups = None -class UserEntityBaseParameters(msrest.serialization.Model): +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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :vartype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :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]'}, + "state": {"key": "state", "type": "str"}, + "note": {"key": "note", "type": "str"}, + "identities": {"key": "identities", "type": "[UserIdentityContract]"}, } def __init__( self, *, - state: Optional[Union[str, "UserState"]] = "active", + state: Union[str, "_models.UserState"] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, **kwargs ): """ :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :paramtype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] """ - super(UserEntityBaseParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.note = note self.identities = identities @@ -18137,13 +17901,12 @@ class UserContractProperties(UserEntityBaseParameters): :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :vartype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar first_name: First name. :vartype first_name: str :ivar last_name: Last name. @@ -18154,30 +17917,30 @@ class UserContractProperties(UserEntityBaseParameters): ``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[~api_management_client.models.GroupContractProperties] + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ _validation = { - 'groups': {'readonly': True}, + "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]'}, + "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: Optional[Union[str, "UserState"]] = "active", + state: Union[str, "_models.UserState"] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, first_name: Optional[str] = None, last_name: Optional[str] = None, email: Optional[str] = None, @@ -18187,13 +17950,12 @@ def __init__( """ :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :paramtype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword first_name: First name. :paramtype first_name: str :keyword last_name: Last name. @@ -18204,7 +17966,7 @@ def __init__( format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :paramtype registration_date: ~datetime.datetime """ - super(UserContractProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) + super().__init__(state=state, note=note, identities=identities, **kwargs) self.first_name = first_name self.last_name = last_name self.email = email @@ -18219,46 +17981,45 @@ class UserCreateParameterProperties(UserEntityBaseParameters): :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :vartype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] - :ivar email: Required. Email address. Must not be empty and must be unique within the service - instance. + :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: Required. First name. + :ivar first_name: First name. Required. :vartype first_name: str - :ivar last_name: Required. Last name. + :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. Possible values include: "portal", "developerPortal". - :vartype app_type: str or ~api_management_client.models.AppType + 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. Possible values include: "signup", "invite". - :vartype confirmation: str or ~api_management_client.models.Confirmation + 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}, + "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'}, + "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__( @@ -18267,41 +18028,40 @@ def __init__( email: str, first_name: str, last_name: str, - state: Optional[Union[str, "UserState"]] = "active", + state: Union[str, "_models.UserState"] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, password: Optional[str] = None, - app_type: Optional[Union[str, "AppType"]] = None, - confirmation: Optional[Union[str, "Confirmation"]] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + confirmation: Optional[Union[str, "_models.Confirmation"]] = None, **kwargs ): """ :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :paramtype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] - :keyword email: Required. Email address. Must not be empty and must be unique within the - service instance. + :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: Required. First name. + :keyword first_name: First name. Required. :paramtype first_name: str - :keyword last_name: Required. Last name. + :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. Possible values include: "portal", "developerPortal". - :paramtype app_type: str or ~api_management_client.models.AppType + 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. Possible values include: "signup", "invite". - :paramtype confirmation: str or ~api_management_client.models.Confirmation + newly created user. Known values are: "signup" and "invite". + :paramtype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ - super(UserCreateParameterProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) + super().__init__(state=state, note=note, identities=identities, **kwargs) self.email = email self.first_name = first_name self.last_name = last_name @@ -18310,18 +18070,17 @@ def __init__( self.confirmation = confirmation -class UserCreateParameters(msrest.serialization.Model): +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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :vartype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :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. @@ -18331,55 +18090,54 @@ class UserCreateParameters(msrest.serialization.Model): :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. Possible values include: "portal", "developerPortal". - :vartype app_type: str or ~api_management_client.models.AppType + 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. Possible values include: "signup", "invite". - :vartype confirmation: str or ~api_management_client.models.Confirmation + 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}, + "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'}, + "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: Optional[Union[str, "UserState"]] = "active", + state: Union[str, "_models.UserState"] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = 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, "AppType"]] = None, - confirmation: Optional[Union[str, "Confirmation"]] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + confirmation: Optional[Union[str, "_models.Confirmation"]] = None, **kwargs ): """ :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :paramtype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :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 @@ -18390,13 +18148,13 @@ def __init__( :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. Possible values include: "portal", "developerPortal". - :paramtype app_type: str or ~api_management_client.models.AppType + 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. Possible values include: "signup", "invite". - :paramtype confirmation: str or ~api_management_client.models.Confirmation + newly created user. Known values are: "signup" and "invite". + :paramtype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ - super(UserCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.note = note self.identities = identities @@ -18408,46 +18166,46 @@ def __init__( self.confirmation = confirmation -class UserIdentityCollection(msrest.serialization.Model): +class UserIdentityCollection(_serialization.Model): """List of Users Identity list representation. :ivar value: User Identity values. - :vartype value: list[~api_management_client.models.UserIdentityContract] + :vartype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar count: Total record count number across all pages. - :vartype count: long + :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': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserIdentityContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["UserIdentityContract"]] = None, + value: Optional[List["_models.UserIdentityContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: User Identity values. - :paramtype value: list[~api_management_client.models.UserIdentityContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword count: Total record count number across all pages. - :paramtype count: long + :paramtype count: int :keyword next_link: Next page link if any. :paramtype next_link: str """ - super(UserIdentityCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class UserIdentityContract(msrest.serialization.Model): +class UserIdentityContract(_serialization.Model): """User identity details. :ivar provider: Identity provider name. @@ -18457,16 +18215,12 @@ class UserIdentityContract(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - provider: Optional[str] = None, - id: Optional[str] = None, - **kwargs + self, *, provider: Optional[str] = None, id: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin ): """ :keyword provider: Identity provider name. @@ -18474,12 +18228,12 @@ def __init__( :keyword id: Identifier value within provider. :paramtype id: str """ - super(UserIdentityContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.id = id -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -18489,34 +18243,28 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "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 - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :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(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class UserTokenParameters(msrest.serialization.Model): +class UserTokenParameters(_serialization.Model): """Get User Token parameters. - :ivar key_type: The Key to be used to generate token for user. Possible values include: - "primary", "secondary". - :vartype key_type: str or ~api_management_client.models.KeyType + :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. @@ -18524,32 +18272,32 @@ class UserTokenParameters(msrest.serialization.Model): """ _attribute_map = { - 'key_type': {'key': 'properties.keyType', 'type': 'str'}, - 'expiry': {'key': 'properties.expiry', 'type': 'iso-8601'}, + "key_type": {"key": "properties.keyType", "type": "str"}, + "expiry": {"key": "properties.expiry", "type": "iso-8601"}, } def __init__( self, *, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, expiry: Optional[datetime.datetime] = None, **kwargs ): """ - :keyword key_type: The Key to be used to generate token for user. Possible values include: - "primary", "secondary". - :paramtype key_type: str or ~api_management_client.models.KeyType + :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(UserTokenParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.expiry = expiry -class UserTokenResult(msrest.serialization.Model): +class UserTokenResult(_serialization.Model): """Get User Token response details. :ivar value: Shared Access Authorization token for the User. @@ -18557,35 +18305,29 @@ class UserTokenResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, **kwargs): """ :keyword value: Shared Access Authorization token for the User. :paramtype value: str """ - super(UserTokenResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UserUpdateParameters(msrest.serialization.Model): +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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :vartype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :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. @@ -18597,27 +18339,27 @@ class UserUpdateParameters(msrest.serialization.Model): """ _validation = { - 'email': {'max_length': 254, 'min_length': 1}, - 'first_name': {'max_length': 100, 'min_length': 1}, - 'last_name': {'max_length': 100, 'min_length': 1}, + "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'}, + "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: Optional[Union[str, "UserState"]] = "active", + state: Union[str, "_models.UserState"] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, email: Optional[str] = None, password: Optional[str] = None, first_name: Optional[str] = None, @@ -18627,13 +18369,12 @@ def __init__( """ :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :paramtype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :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 @@ -18644,7 +18385,7 @@ def __init__( :keyword last_name: Last name. :paramtype last_name: str """ - super(UserUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.note = note self.identities = identities @@ -18659,13 +18400,12 @@ class UserUpdateParametersProperties(UserEntityBaseParameters): :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :vartype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :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. @@ -18677,27 +18417,27 @@ class UserUpdateParametersProperties(UserEntityBaseParameters): """ _validation = { - 'email': {'max_length': 254, 'min_length': 1}, - 'first_name': {'max_length': 100, 'min_length': 1}, - 'last_name': {'max_length': 100, 'min_length': 1}, + "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'}, + "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: Optional[Union[str, "UserState"]] = "active", + state: Union[str, "_models.UserState"] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, email: Optional[str] = None, password: Optional[str] = None, first_name: Optional[str] = None, @@ -18707,13 +18447,12 @@ def __init__( """ :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. Possible values include: "active", "blocked", "pending", "deleted". Default value: - "active". - :paramtype state: str or ~api_management_client.models.UserState + 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[~api_management_client.models.UserIdentityContract] + :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 @@ -18724,14 +18463,14 @@ def __init__( :keyword last_name: Last name. :paramtype last_name: str """ - super(UserUpdateParametersProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) + 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(msrest.serialization.Model): +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. @@ -18746,35 +18485,32 @@ class VirtualNetworkConfiguration(msrest.serialization.Model): """ _validation = { - 'vnetid': {'readonly': True}, - 'subnetname': {'readonly': True}, - 'subnet_resource_id': {'pattern': r'^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$'}, + "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'}, + "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 - ): + def __init__(self, *, subnet_resource_id: Optional[str] = None, **kwargs): """ :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(VirtualNetworkConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.vnetid = None self.subnetname = None self.subnet_resource_id = subnet_resource_id -class X509CertificateName(msrest.serialization.Model): +class X509CertificateName(_serialization.Model): """Properties of server X509Names. :ivar name: Common Name of the Certificate. @@ -18784,23 +18520,17 @@ class X509CertificateName(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'issuer_certificate_thumbprint': {'key': 'issuerCertificateThumbprint', 'type': 'str'}, + "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 - ): + def __init__(self, *, name: Optional[str] = None, issuer_certificate_thumbprint: Optional[str] = None, **kwargs): """ :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(X509CertificateName, self).__init__(**kwargs) + 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 new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""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 + + +def patch_sdk(): + """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/operations/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/__init__.py index 9f8b6482fabbe..898ea8cdf5325 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 @@ -83,81 +83,87 @@ from ._user_identities_operations import UserIdentitiesOperations from ._user_confirmation_password_operations import UserConfirmationPasswordOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ApiOperations', - 'ApiRevisionOperations', - 'ApiReleaseOperations', - 'ApiOperationOperations', - 'ApiOperationPolicyOperations', - 'TagOperations', - 'ApiProductOperations', - 'ApiPolicyOperations', - 'ApiSchemaOperations', - 'ApiDiagnosticOperations', - 'ApiIssueOperations', - 'ApiIssueCommentOperations', - 'ApiIssueAttachmentOperations', - 'ApiTagDescriptionOperations', - 'OperationOperations', - 'ApiExportOperations', - 'ApiVersionSetOperations', - 'AuthorizationServerOperations', - 'BackendOperations', - 'CacheOperations', - 'CertificateOperations', - 'ApiManagementClientOperationsMixin', - 'ContentTypeOperations', - 'ContentItemOperations', - 'DeletedServicesOperations', - 'ApiManagementOperationsOperations', - 'ApiManagementServiceSkusOperations', - 'ApiManagementServiceOperations', - 'DiagnosticOperations', - 'EmailTemplateOperations', - 'GatewayOperations', - 'GatewayHostnameConfigurationOperations', - 'GatewayApiOperations', - 'GatewayCertificateAuthorityOperations', - 'GroupOperations', - 'GroupUserOperations', - 'IdentityProviderOperations', - 'IssueOperations', - 'LoggerOperations', - 'NamedValueOperations', - 'NetworkStatusOperations', - 'NotificationOperations', - 'NotificationRecipientUserOperations', - 'NotificationRecipientEmailOperations', - 'OpenIdConnectProviderOperations', - 'OutboundNetworkDependenciesEndpointsOperations', - 'PolicyOperations', - 'PolicyDescriptionOperations', - 'PortalRevisionOperations', - 'PortalSettingsOperations', - 'SignInSettingsOperations', - 'SignUpSettingsOperations', - 'DelegationSettingsOperations', - 'PrivateEndpointConnectionOperations', - 'ProductOperations', - 'ProductApiOperations', - 'ProductGroupOperations', - 'ProductSubscriptionsOperations', - 'ProductPolicyOperations', - 'QuotaByCounterKeysOperations', - 'QuotaByPeriodKeysOperations', - 'RegionOperations', - 'ReportsOperations', - 'GlobalSchemaOperations', - 'TenantSettingsOperations', - 'ApiManagementSkusOperations', - 'SubscriptionOperations', - 'TagResourceOperations', - 'TenantAccessOperations', - 'TenantAccessGitOperations', - 'TenantConfigurationOperations', - 'UserOperations', - 'UserGroupOperations', - 'UserSubscriptionOperations', - 'UserIdentitiesOperations', - 'UserConfirmationPasswordOperations', + "ApiOperations", + "ApiRevisionOperations", + "ApiReleaseOperations", + "ApiOperationOperations", + "ApiOperationPolicyOperations", + "TagOperations", + "ApiProductOperations", + "ApiPolicyOperations", + "ApiSchemaOperations", + "ApiDiagnosticOperations", + "ApiIssueOperations", + "ApiIssueCommentOperations", + "ApiIssueAttachmentOperations", + "ApiTagDescriptionOperations", + "OperationOperations", + "ApiExportOperations", + "ApiVersionSetOperations", + "AuthorizationServerOperations", + "BackendOperations", + "CacheOperations", + "CertificateOperations", + "ApiManagementClientOperationsMixin", + "ContentTypeOperations", + "ContentItemOperations", + "DeletedServicesOperations", + "ApiManagementOperationsOperations", + "ApiManagementServiceSkusOperations", + "ApiManagementServiceOperations", + "DiagnosticOperations", + "EmailTemplateOperations", + "GatewayOperations", + "GatewayHostnameConfigurationOperations", + "GatewayApiOperations", + "GatewayCertificateAuthorityOperations", + "GroupOperations", + "GroupUserOperations", + "IdentityProviderOperations", + "IssueOperations", + "LoggerOperations", + "NamedValueOperations", + "NetworkStatusOperations", + "NotificationOperations", + "NotificationRecipientUserOperations", + "NotificationRecipientEmailOperations", + "OpenIdConnectProviderOperations", + "OutboundNetworkDependenciesEndpointsOperations", + "PolicyOperations", + "PolicyDescriptionOperations", + "PortalRevisionOperations", + "PortalSettingsOperations", + "SignInSettingsOperations", + "SignUpSettingsOperations", + "DelegationSettingsOperations", + "PrivateEndpointConnectionOperations", + "ProductOperations", + "ProductApiOperations", + "ProductGroupOperations", + "ProductSubscriptionsOperations", + "ProductPolicyOperations", + "QuotaByCounterKeysOperations", + "QuotaByPeriodKeysOperations", + "RegionOperations", + "ReportsOperations", + "GlobalSchemaOperations", + "TenantSettingsOperations", + "ApiManagementSkusOperations", + "SubscriptionOperations", + "TagResourceOperations", + "TenantAccessOperations", + "TenantAccessGitOperations", + "TenantConfigurationOperations", + "UserOperations", + "UserGroupOperations", + "UserSubscriptionOperations", + "UserIdentitiesOperations", + "UserConfirmationPasswordOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py index 3dd52b858228c..845a0696db63a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,118 +47,130 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, diagnostic_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, diagnostic_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -159,48 +180,51 @@ def build_create_or_update_request( diagnostic_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -211,46 +235,49 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -263,58 +290,64 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiDiagnosticOperations(object): - """ApiDiagnosticOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -326,37 +359,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DiagnosticCollection"]: + ) -> Iterable["_models.DiagnosticContract"]: """Lists all diagnostics of an API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.DiagnosticCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -365,25 +408,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,7 +437,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,56 +449,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - api_id: str, - diagnostic_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -465,60 +514,67 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - diagnostic_id: str, - **kwargs: Any - ) -> "_models.DiagnosticContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -527,17 +583,94 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -546,40 +679,57 @@ def create_or_update( service_name: str, api_id: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic for an API or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DiagnosticContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -587,15 +737,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -605,22 +762,99 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -630,39 +864,56 @@ def update( api_id: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Diagnostic Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DiagnosticContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, @@ -670,15 +921,22 @@ def update( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -687,54 +945,55 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - api_id: str, - diagnostic_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -742,12 +1001,18 @@ def delete( diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -758,5 +1023,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # 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 index a357e2989249e..79b20b3bf2bce 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,100 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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"], + format: Union[str, _models.ExportFormat], + export: Union[str, _models.ExportApi], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['export'] = _SERIALIZER.query("export", export, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiExportOperations(object): - """ApiExportOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -94,37 +107,45 @@ def get( resource_group_name: str, service_name: str, api_id: str, - format: Union[str, "_models.ExportFormat"], - export: Union[str, "_models.ExportApi"], + format: Union[str, _models.ExportFormat], + export: Union[str, _models.ExportApi], **kwargs: Any - ) -> "_models.ApiExportResult": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type format: str or ~api_management_client.models.ExportFormat - :param export: Query parameter required to export the API details. - :type export: str or ~api_management_client.models.ExportApi + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiExportResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiExportResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiExportResult] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -132,12 +153,18 @@ def get( subscription_id=self._config.subscription_id, format=format, export=export, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,12 +172,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiExportResult', pipeline_response) + deserialized = self._deserialize("ApiExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py index a8fd53b22ce00..346adb5f5f31a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,41 +48,49 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_tag_request( @@ -85,36 +102,46 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -126,36 +153,46 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -166,49 +203,54 @@ def build_create_or_update_request( attachment_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -222,59 +264,67 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiIssueAttachmentOperations(object): - """ApiIssueAttachmentOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -287,41 +337,52 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueAttachmentCollection"]: + ) -> Iterable["_models.IssueAttachmentContract"]: """Lists all attachments for the Issue associated with the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueAttachmentCollection or the result of + :return: An iterator like instance of either IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueAttachmentCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueAttachmentCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -331,26 +392,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -364,7 +421,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -374,49 +433,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + Issue. Required. :type attachment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, @@ -424,12 +483,18 @@ def get_entity_tag( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -438,52 +503,52 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + Issue. Required. :type attachment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueAttachmentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueAttachmentContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -491,12 +556,18 @@ def get( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -505,17 +576,102 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -525,43 +681,60 @@ def create_or_update( api_id: str, issue_id: str, attachment_id: str, - parameters: "_models.IssueAttachmentContract", + parameters: Union[_models.IssueAttachmentContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueAttachmentContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + Issue. Required. :type attachment_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueAttachmentContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueAttachmentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueAttachmentContract] - _json = self._serialize.body(parameters, 'IssueAttachmentContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueAttachmentContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -570,15 +743,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -588,25 +768,24 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -618,33 +797,41 @@ def delete( ) -> None: """Deletes the specified comment from an Issue. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -653,12 +840,18 @@ def delete( attachment_id=attachment_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -669,5 +862,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # 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 index 2501492d60708..ea4849434dd43 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,41 +48,49 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_tag_request( @@ -85,36 +102,46 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -126,36 +153,46 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -166,49 +203,54 @@ def build_create_or_update_request( comment_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -222,59 +264,67 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiIssueCommentOperations(object): - """ApiIssueCommentOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -287,41 +337,52 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueCommentCollection"]: + ) -> Iterable["_models.IssueCommentContract"]: """Lists all comments for the Issue associated with the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueCommentCollection or the result of + :return: An iterator like instance of either IssueCommentContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueCommentCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueCommentContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCommentCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -331,26 +392,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -364,7 +421,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -374,48 +433,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, @@ -423,12 +483,18 @@ def get_entity_tag( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -437,51 +503,52 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 callable cls: A custom type or function that will be passed the direct response - :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueCommentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCommentContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -489,12 +556,18 @@ def get( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -503,17 +576,102 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueCommentContract', pipeline_response) + deserialized = self._deserialize("IssueCommentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -523,42 +681,60 @@ def create_or_update( api_id: str, issue_id: str, comment_id: str, - parameters: "_models.IssueCommentContract", + parameters: Union[_models.IssueCommentContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueCommentContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. - :type parameters: ~api_management_client.models.IssueCommentContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueCommentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCommentContract] - _json = self._serialize.body(parameters, 'IssueCommentContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueCommentContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -567,15 +743,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -585,25 +768,24 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueCommentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueCommentContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueCommentContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueCommentContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -615,32 +797,41 @@ def delete( ) -> None: """Deletes the specified comment from an Issue. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -649,12 +840,18 @@ def delete( comment_id=comment_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -665,5 +862,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # 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 index f6344b38055ae..c0c6c57adf21b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,81 +48,92 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = _SERIALIZER.query("expand_comments_attachments", expand_comments_attachments, 'bool') + _params["expandCommentsAttachments"] = _SERIALIZER.query( + "expand_comments_attachments", expand_comments_attachments, "bool" + ) if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, issue_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -126,37 +146,47 @@ def build_get_request( expand_comments_attachments: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = _SERIALIZER.query("expand_comments_attachments", expand_comments_attachments, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["expandCommentsAttachments"] = _SERIALIZER.query( + "expand_comments_attachments", expand_comments_attachments, "bool" + ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -166,48 +196,51 @@ def build_create_or_update_request( issue_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -218,46 +251,49 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -270,58 +306,64 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiIssueOperations(object): - """ApiIssueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -334,40 +376,50 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueCollection"]: + ) -> Iterable["_models.IssueContract"]: """Lists all issues associated with the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + filter | eq | |
. Default value is None. :type filter: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -377,26 +429,22 @@ def prepare_request(next_link=None): expand_comments_attachments=expand_comments_attachments, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,7 +458,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -420,56 +470,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -478,15 +535,13 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace def get( @@ -497,32 +552,40 @@ def get( issue_id: str, expand_comments_attachments: Optional[bool] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -530,12 +593,18 @@ def get( issue_id=issue_id, subscription_id=self._config.subscription_id, expand_comments_attachments=expand_comments_attachments, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,17 +613,94 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueContract', pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -563,40 +709,57 @@ def create_or_update( service_name: str, api_id: str, issue_id: str, - parameters: "_models.IssueContract", + parameters: Union[_models.IssueContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Creates a new Issue for an API or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'IssueContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -604,15 +767,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -622,22 +792,99 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IssueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -647,39 +894,56 @@ def update( api_id: str, issue_id: str, if_match: str, - parameters: "_models.IssueUpdateContract", + parameters: Union[_models.IssueUpdateContract, IO], **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Updates an existing issue for an API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IssueUpdateContract + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] - _json = self._serialize.body(parameters, 'IssueUpdateContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IssueUpdateContract") request = build_update_request( resource_group_name=resource_group_name, @@ -687,15 +951,22 @@ def update( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -704,54 +975,55 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueContract', pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -759,12 +1031,18 @@ def delete( issue_id=issue_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -775,5 +1053,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # 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 index cd244845fc934..0d10a963e8352 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,138 +6,242 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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_initial( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_perform_connectivity_check_async_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ApiManagementClientOperationsMixin(object): +class ApiManagementClientOperationsMixin(MixinABC): def _perform_connectivity_check_async_initial( self, resource_group_name: str, service_name: str, - connectivity_check_request_params: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO], **kwargs: Any - ) -> Optional["_models.ConnectivityCheckResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConnectivityCheckResponse"]] + ) -> Optional[_models.ConnectivityCheckResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connectivity_check_request_params, 'ConnectivityCheckRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ConnectivityCheckResponse]] - request = build_perform_connectivity_check_async_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connectivity_check_request_params, (IO, 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, - template_url=self._perform_connectivity_check_async_initial.metadata['url'], + content=_content, + template_url=self._perform_connectivity_check_async_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ConnectivityCheckResponse', pipeline_response) + deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _perform_connectivity_check_async_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + _perform_connectivity_check_async_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectivityCheckResponse"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. - :type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest + :param connectivity_check_request_params: Connectivity Check request parameters. Is either a + model type or a IO type. Required. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -147,47 +252,54 @@ def begin_perform_connectivity_check_async( Retry-After header is present. :return: An instance of LROPoller that returns either ConnectivityCheckResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.ConnectivityCheckResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectivityCheckResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectivityCheckResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._perform_connectivity_check_async_initial( + raw_result = self._perform_connectivity_check_async_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ConnectivityCheckResponse', pipeline_response) + deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_perform_connectivity_check_async.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + begin_perform_connectivity_check_async.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py index 5777a7c231cd7..2c80678db13b6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request + +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: - api_version = "2021-08-01" - accept = "application/json" + +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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.ApiManagement/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.ApiManagement/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiManagementOperationsOperations(object): - """ApiManagementOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available REST API operations of the Microsoft.ApiManagement provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +130,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +142,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.ApiManagement/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ApiManagement/operations"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py index 962b9e7ce1e8f..cab989a453e1b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,577 +6,649 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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_initial( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_restore_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_backup_request_initial( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_create_or_update_request_initial( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_update_request_initial( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_delete_request_initial( - resource_group_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any + _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: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service') + _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'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" +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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability') + _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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_get_domain_ownership_identifier_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier') + _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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_apply_network_configuration_updates_request_initial( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class ApiManagementServiceOperations(object): - """ApiManagementServiceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - request = build_restore_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self._restore_initial.metadata['url'], + content=_content, + template_url=self._restore_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + _restore_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -587,115 +660,220 @@ def begin_restore( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._restore_initial( + raw_result = self._restore_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + begin_restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # type: ignore def _backup_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementServiceBackupRestoreParameters") - request = build_backup_request_initial( + 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, - template_url=self._backup_initial.metadata['url'], + content=_content, + template_url=self._backup_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + _backup_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Parameters supplied to the ApiManagementService_Backup operation. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + :param parameters: Parameters supplied to the ApiManagementService_Backup operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -707,118 +885,224 @@ def begin_backup( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._backup_initial( + raw_result = self._backup_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + begin_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceResource", + parameters: Union[_models.ApiManagementServiceResource, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiManagementServiceResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementServiceResource") - request = build_create_or_update_request_initial( + 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, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceResource", + parameters: Union[_models.ApiManagementServiceResource, IO], **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.ApiManagementServiceResource + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -830,114 +1114,216 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceUpdateParameters", + parameters: Union[_models.ApiManagementServiceUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - _json = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementServiceUpdateParameters") - request = build_update_request_initial( + 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, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.ApiManagementServiceUpdateParameters", + parameters: Union[_models.ApiManagementServiceUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> LROPoller[_models.ApiManagementServiceResource]: """Updates an existing API Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.ApiManagementServiceUpdateParameters + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -949,86 +1335,98 @@ def begin_update( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ApiManagementServiceResource": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceResource, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1036,69 +1434,73 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] + + request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + def begin_delete(self, resource_group_name: str, service_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an existing API Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1111,90 +1513,103 @@ def begin_delete( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ApiManagementServiceListResult"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiManagementServiceListResult or the result of + :return: An iterator like instance of either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.ApiManagementServiceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1208,7 +1623,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1218,49 +1635,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.ApiManagementServiceListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.ApiManagementServiceResource"]: """Lists all API Management services within an Azure subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiManagementServiceListResult or the result of + :return: An iterator like instance of either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.ApiManagementServiceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1274,7 +1698,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1284,47 +1710,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace def get_sso_token( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.ApiManagementServiceGetSsoTokenResult": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceGetSsoTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetSsoTokenResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiManagementServiceGetSsoTokenResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetSsoTokenResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceGetSsoTokenResult] - request = build_get_sso_token_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_sso_token.metadata['url'], + api_version=api_version, + template_url=self.get_sso_token.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1332,52 +1766,112 @@ def get_sso_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceGetSsoTokenResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceGetSsoTokenResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore - + get_sso_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, - parameters: "_models.ApiManagementServiceCheckNameAvailabilityParameters", + parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ApiManagementServiceNameAvailabilityResult": + ) -> _models.ApiManagementServiceNameAvailabilityResult: """Checks availability and correctness of a name for an API Management service. - :param parameters: Parameters supplied to the CheckNameAvailability operation. + :param parameters: Parameters supplied to the CheckNameAvailability operation. Required. :type parameters: - ~api_management_client.models.ApiManagementServiceCheckNameAvailabilityParameters + ~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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, *, 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceNameAvailabilityResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :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], **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 + model type or a IO type. Required. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiManagementServiceNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceNameAvailabilityResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceNameAvailabilityResult] - _json = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1385,43 +1879,54 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability"} # type: ignore @distributed_trace def get_domain_ownership_identifier( - self, - **kwargs: Any - ) -> "_models.ApiManagementServiceGetDomainOwnershipIdentifierResult": + self, **kwargs: Any + ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: """Get the custom domain ownership identifier for an API Management service. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiManagementServiceGetDomainOwnershipIdentifierResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetDomainOwnershipIdentifierResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiManagementServiceGetDomainOwnershipIdentifierResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetDomainOwnershipIdentifierResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceGetDomainOwnershipIdentifierResult] - request = build_get_domain_ownership_identifier_request( subscription_id=self._config.subscription_id, - template_url=self.get_domain_ownership_identifier.metadata['url'], + api_version=api_version, + template_url=self.get_domain_ownership_identifier.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1429,86 +1934,188 @@ def get_domain_ownership_identifier( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApiManagementServiceGetDomainOwnershipIdentifierResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_domain_ownership_identifier.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier'} # type: ignore - + get_domain_ownership_identifier.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier"} # type: ignore def _apply_network_configuration_updates_initial( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO]] = None, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] - if parameters is not None: - _json = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ApiManagementServiceApplyNetworkConfigurationParameters") + else: + _json = None - request = build_apply_network_configuration_updates_request_initial( + 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, - template_url=self._apply_network_configuration_updates_initial.metadata['url'], + content=_content, + template_url=self._apply_network_configuration_updates_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _apply_network_configuration_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + _apply_network_configuration_updates_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # type: ignore + @overload + def begin_apply_network_configuration_updates( + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[IO] = 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + updated sequentially without incurring downtime in the region. Is either a model type or a IO + type. Default value is None. :type parameters: - ~api_management_client.models.ApiManagementServiceApplyNetworkConfigurationParameters + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1520,47 +2127,53 @@ def begin_apply_network_configuration_updates( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._apply_network_configuration_updates_initial( + raw_result = self._apply_network_configuration_updates_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_apply_network_configuration_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + begin_apply_network_configuration_updates.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # 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 index 02c38580d51ed..7da9ebe2a8943 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,130 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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( - resource_group_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiManagementServiceSkusOperations(object): - """ApiManagementServiceSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ResourceSkuResults"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ResourceSkuResults] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuResults"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceSkuResults] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_available_service_skus.metadata['url'], + api_version=api_version, + template_url=self.list_available_service_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_available_service_skus_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -142,7 +160,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -152,8 +172,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_available_service_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus'} # type: ignore + list_available_service_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py index a41bb26691b64..62b0b8b4e2b43 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,115 +6,123 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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: - api_version = "2021-08-01" - accept = "application/json" + +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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiManagementSkusOperations(object): - """ApiManagementSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ApiManagementSkusResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.ApiManagementSku"]: """Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiManagementSkusResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiManagementSkusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementSkusResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiManagementSkusResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,7 +136,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -137,8 +148,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py index 8f1aa1bc8117a..b76e11e632a0e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,120 +48,128 @@ def build_list_by_api_request( tags: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if tags is not None: - query_parameters['tags'] = _SERIALIZER.query("tags", tags, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -162,48 +179,49 @@ def build_create_or_update_request( operation_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -214,46 +232,47 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -266,58 +285,62 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiOperationOperations(object): - """ApiOperationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -330,15 +353,15 @@ def list_by_api( skip: Optional[int] = None, tags: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.OperationCollection"]: + ) -> Iterable["_models.OperationContract"]: """Lists a collection of the operations for the specified API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 | @@ -347,27 +370,36 @@ def list_by_api( |
| 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 |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :param tags: Include tags in the response. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.OperationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -377,26 +409,22 @@ def prepare_request(next_link=None): top=top, skip=skip, tags=tags, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,7 +438,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -420,57 +450,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - api_id: str, - operation_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -479,61 +515,67 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - operation_id: str, - **kwargs: Any - ) -> "_models.OperationContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,17 +584,94 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OperationContract', pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -561,41 +680,57 @@ def create_or_update( service_name: str, api_id: str, operation_id: str, - parameters: "_models.OperationContract", + parameters: Union[_models.OperationContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Creates a new operation in the API or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OperationContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationContract] - _json = self._serialize.body(parameters, 'OperationContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -603,15 +738,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -621,22 +763,99 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OperationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OperationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -646,40 +865,57 @@ def update( api_id: str, operation_id: str, if_match: str, - parameters: "_models.OperationUpdateContract", + parameters: Union[_models.OperationUpdateContract, IO], **kwargs: Any - ) -> "_models.OperationContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: API Operation Update parameters. - :type parameters: ~api_management_client.models.OperationUpdateContract + :param parameters: API Operation Update parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'OperationUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationUpdateContract") request = build_update_request( resource_group_name=resource_group_name, @@ -687,15 +923,22 @@ def update( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -704,55 +947,55 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OperationContract', pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - api_id: str, - operation_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -760,12 +1003,18 @@ def delete( operation_id=operation_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -776,5 +1025,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # 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 index 2cc176950b641..f15f2ddd776b2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,64 +6,72 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, api_id: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_tag_request( @@ -70,40 +79,46 @@ def build_get_entity_tag_request( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -111,44 +126,50 @@ def build_get_request( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -156,52 +177,53 @@ def build_create_or_update_request( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -209,111 +231,123 @@ def build_delete_request( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiOperationPolicyOperations(object): - """ApiOperationPolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - 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, - template_url=self.list_by_operation.metadata['url'], + api_version=api_version, + template_url=self.list_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -321,15 +355,14 @@ def list_by_operation( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies'} # type: ignore - + list_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies"} # type: ignore @distributed_trace def get_entity_tag( @@ -338,35 +371,42 @@ def get_entity_tag( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, @@ -374,12 +414,18 @@ def get_entity_tag( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -388,15 +434,13 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace def get( @@ -405,38 +449,46 @@ def get( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API Operation level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -445,12 +497,18 @@ def get( policy_id=policy_id, subscription_id=self._config.subscription_id, format=format, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -459,17 +517,100 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PolicyContract', pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -478,44 +619,60 @@ def create_or_update( service_name: str, api_id: str, operation_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API Operation level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - _json = self._serialize.body(parameters, 'PolicyContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -524,15 +681,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -542,63 +706,69 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + 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"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + Management service instance. Required. :type operation_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -607,12 +777,18 @@ def delete( policy_id=policy_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -623,5 +799,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # 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 index e82a954a2e596..6ef84e2f2e737 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,30 +6,38 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -41,214 +50,220 @@ def build_list_by_service_request( expand_api_version_set: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if tags is not None: - query_parameters['tags'] = _SERIALIZER.query("tags", tags, 'str') + _params["tags"] = _SERIALIZER.query("tags", tags, "str") if expand_api_version_set is not None: - query_parameters['expandApiVersionSet'] = _SERIALIZER.query("expand_api_version_set", expand_api_version_set, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, service_name: str, api_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -261,37 +276,43 @@ def build_delete_request( delete_revisions: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if delete_revisions is not None: - query_parameters['deleteRevisions'] = _SERIALIZER.query("delete_revisions", delete_revisions, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["deleteRevisions"] = _SERIALIZER.query("delete_revisions", delete_revisions, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_tags_request( @@ -305,63 +326,67 @@ def build_list_by_tags_request( include_not_tagged_apis: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if include_not_tagged_apis is not None: - query_parameters['includeNotTaggedApis'] = _SERIALIZER.query("include_not_tagged_apis", include_not_tagged_apis, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiOperations(object): - """ApiOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -374,12 +399,12 @@ def list_by_service( tags: Optional[str] = None, expand_api_version_set: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.ApiCollection"]: + ) -> Iterable["_models.ApiContract"]: """Lists all APIs of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -388,29 +413,39 @@ def list_by_service( |
| 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 | |
. + startswith, endswith |
| isCurrent | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :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. + :param expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. :type expand_api_version_set: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -420,26 +455,22 @@ def prepare_request(next_link=None): skip=skip, tags=tags, expand_api_version_set=expand_api_version_set, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +484,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,52 +496,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - api_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -517,56 +555,61 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - **kwargs: Any - ) -> "_models.ApiContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -575,76 +618,181 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: Union[_models.ApiCreateOrUpdateParameter, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.ApiContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiContract"]] + ) -> Optional[_models.ApiContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApiContract]] - _json = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiCreateOrUpdateParameter") - request = build_create_or_update_request_initial( + 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -652,24 +800,27 @@ def begin_create_or_update( resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: Union[_models.ApiCreateOrUpdateParameter, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.ApiContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type parameters: ~api_management_client.models.ApiCreateOrUpdateParameter + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -680,55 +831,132 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either ApiContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.ApiContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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('ApiContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -737,52 +965,76 @@ def update( service_name: str, api_id: str, if_match: str, - parameters: "_models.ApiUpdateContract", + parameters: Union[_models.ApiUpdateContract, IO], **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Updates the specified API of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: API Update Contract parameters. - :type parameters: ~api_management_client.models.ApiUpdateContract + :param parameters: API Update Contract parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,20 +1043,19 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -815,30 +1066,37 @@ def delete( ) -> None: """Deletes the specified API of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + :param delete_revisions: Delete all revisions of the Api. Default value is None. :type delete_revisions: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -846,12 +1104,18 @@ def delete( subscription_id=self._config.subscription_id, if_match=if_match, delete_revisions=delete_revisions, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -862,8 +1126,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace def list_by_tags( @@ -875,12 +1138,12 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_apis: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable["_models.TagResourceContract"]: """Lists a collection of apis associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -890,28 +1153,37 @@ def list_by_tags( 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 | |
. + contains, startswith, endswith |
| isCurrent | filter | eq | |
. Default value is + None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_apis: Include not tagged APIs. + :param include_not_tagged_apis: Include not tagged APIs. Default value is None. :type include_not_tagged_apis: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -920,25 +1192,22 @@ def prepare_request(next_link=None): top=top, skip=skip, include_not_tagged_apis=include_not_tagged_apis, - template_url=self.list_by_tags.metadata['url'], + api_version=api_version, + template_url=self.list_by_tags.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -952,7 +1221,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,8 +1233,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags'} # type: ignore + list_by_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py index e4d0598ec0d55..451a6431ee7a4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,300 +6,338 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ApiPolicyOperations(object): - """ApiPolicyOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - 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, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,15 +345,14 @@ def list_by_api( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies'} # type: ignore - + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies"} # type: ignore @distributed_trace def get_entity_tag( @@ -322,44 +360,57 @@ def get_entity_tag( resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -368,15 +419,13 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace def get( @@ -384,35 +433,43 @@ def get( resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -420,12 +477,18 @@ def get( policy_id=policy_id, subscription_id=self._config.subscription_id, format=format, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 200]: @@ -435,22 +498,97 @@ def get( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -458,41 +596,57 @@ def create_or_update( resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - _json = self._serialize.body(parameters, 'PolicyContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -500,15 +654,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -518,59 +679,65 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, api_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -578,12 +745,18 @@ def delete( policy_id=policy_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -594,5 +767,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # 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 index e3f4abe61ecdc..9602017563857 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,62 +47,66 @@ def build_list_by_apis_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiProductOperations(object): - """ApiProductOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -104,36 +118,47 @@ def list_by_apis( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ProductCollection"]: + ) -> Iterable["_models.ProductContract"]: """Lists all Products, which the API is part of. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ProductCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -142,25 +167,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_apis.metadata['url'], + api_version=api_version, + template_url=self.list_by_apis.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -174,7 +196,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,8 +208,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_apis.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products'} # type: ignore + list_by_apis.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py index e75d1fab92dcd..1c5584dbffb54 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,118 +47,130 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, release_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, release_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -159,48 +180,51 @@ def build_create_or_update_request( release_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -211,46 +235,49 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -263,58 +290,64 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiReleaseOperations(object): - """ApiReleaseOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -326,39 +359,49 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiReleaseCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiReleaseCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiReleaseCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -367,25 +410,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -399,7 +439,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,56 +451,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - api_id: str, - release_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type release_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,60 +516,67 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - release_id: str, - **kwargs: Any - ) -> "_models.ApiReleaseContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type release_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -529,17 +585,94 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -548,40 +681,57 @@ def create_or_update( service_name: str, api_id: str, release_id: str, - parameters: "_models.ApiReleaseContract", + parameters: Union[_models.ApiReleaseContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Creates a new Release for the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type release_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiReleaseContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -589,15 +739,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -607,22 +764,99 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # 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. Required. + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -632,39 +866,57 @@ def update( api_id: str, release_id: str, if_match: str, - parameters: "_models.ApiReleaseContract", + parameters: Union[_models.ApiReleaseContract, IO], **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: API Release Update parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :param parameters: API Release Update parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiReleaseContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiReleaseContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, @@ -672,15 +924,22 @@ def update( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -689,54 +948,55 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - api_id: str, - release_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -744,12 +1004,18 @@ def delete( release_id=release_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -760,5 +1026,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # 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 index 0b97f0eb64af9..1a582fe66195a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,62 +47,66 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiRevisionOperations(object): - """ApiRevisionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -104,37 +118,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiRevisionCollection"]: + ) -> Iterable["_models.ApiRevisionContract"]: """Lists all revisions of an API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiRevisionCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiRevisionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiRevisionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -143,25 +167,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -175,7 +196,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,8 +208,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py index 7a9726679060b..d4007c0c3e67a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,30 +6,38 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -40,169 +49,178 @@ def build_list_by_api_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, schema_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, schema_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, service_name: str, api_id: str, schema_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -216,60 +234,64 @@ def build_delete_request( force: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force is not None: - query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["force"] = _SERIALIZER.query("force", force, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiSchemaOperations(object): - """ApiSchemaOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -281,37 +303,47 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SchemaCollection"]: + ) -> Iterable["_models.SchemaContract"]: """Get the schema configuration at the API level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SchemaCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SchemaCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SchemaCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -320,25 +352,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -352,7 +381,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,57 +393,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - api_id: str, - schema_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,61 +458,67 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - schema_id: str, - **kwargs: Any - ) -> "_models.SchemaContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.SchemaContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SchemaContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,17 +527,16 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SchemaContract', pipeline_response) + deserialized = self._deserialize("SchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore def _create_or_update_initial( self, @@ -502,60 +544,174 @@ def _create_or_update_initial( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: Union[_models.SchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.SchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SchemaContract"]] + ) -> Optional[_models.SchemaContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SchemaContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SchemaContract]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SchemaContract", is_xml=True) - request = build_create_or_update_request_initial( + 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -564,27 +720,30 @@ def begin_create_or_update( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: Union[_models.SchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.SchemaContract"]: + ) -> LROPoller[_models.SchemaContract]: """Creates or updates schema configuration for the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + instance. Required. :type schema_id: str - :param parameters: The schema contents to apply. - :type parameters: ~api_management_client.models.SchemaContract + :param parameters: The schema contents to apply. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -595,59 +754,66 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either SchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.SchemaContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SchemaContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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('SchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -659,33 +825,41 @@ def delete( ) -> None: """Deletes the schema configuration at the Api. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + 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. + :param force: If true removes all references to the schema before deleting it. Default value is + None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -694,12 +868,18 @@ def delete( subscription_id=self._config.subscription_id, if_match=if_match, force=force, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -710,5 +890,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # 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 index ff9dc3c66877b..b7df182ef514d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,40 +47,46 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_tag_request( @@ -82,35 +97,43 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -121,35 +144,43 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -159,48 +190,51 @@ def build_create_or_update_request( tag_description_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -213,58 +247,64 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiTagDescriptionOperations(object): - """ApiTagDescriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -276,40 +316,50 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagDescriptionCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagDescriptionCollection or the result of + :return: An iterator like instance of either TagDescriptionContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagDescriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDescriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -318,25 +368,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -350,7 +397,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -360,57 +409,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + API/Tag association. Based on API and Tag names. Required. :type tag_description_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -419,61 +474,67 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_description_id: str, - **kwargs: Any - ) -> "_models.TagDescriptionContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + API/Tag association. Based on API and Tag names. Required. :type tag_description_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagDescriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDescriptionContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -482,17 +543,94 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + deserialized = self._deserialize("TagDescriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -501,41 +639,57 @@ def create_or_update( service_name: str, api_id: str, tag_description_id: str, - parameters: "_models.TagDescriptionCreateParameters", + parameters: Union[_models.TagDescriptionCreateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagDescriptionContract": + ) -> _models.TagDescriptionContract: """Create/Update tag description in scope of the Api. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + API/Tag association. Based on API and Tag names. Required. :type tag_description_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.TagDescriptionCreateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagDescriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagDescriptionCreateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDescriptionContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagDescriptionCreateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -543,15 +697,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -561,25 +722,24 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagDescriptionContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagDescriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -590,31 +750,38 @@ def delete( ) -> None: """Delete tag description for the Api. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -622,12 +789,18 @@ def delete( tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -638,5 +811,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # 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 index f9c42747ca3fc..d390c5fb59f31 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,127 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, version_set_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, version_set_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,47 +175,50 @@ def build_create_or_update_request( version_set_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -202,45 +228,48 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -252,57 +281,63 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ApiVersionSetOperations(object): - """ApiVersionSetOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -313,34 +348,44 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiVersionSetCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
. + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiVersionSetCollection or the result of + :return: An iterator like instance of either ApiVersionSetContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiVersionSetCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -348,24 +393,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -379,7 +422,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,52 +434,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - version_set_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type version_set_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,56 +493,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - version_set_id: str, - **kwargs: Any - ) -> "_models.ApiVersionSetContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type version_set_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,17 +558,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -519,53 +645,76 @@ def create_or_update( resource_group_name: str, service_name: str, version_set_id: str, - parameters: "_models.ApiVersionSetContract", + parameters: Union[_models.ApiVersionSetContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Creates or Updates a Api Version Set. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type version_set_id: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ApiVersionSetContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiVersionSetContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -575,22 +724,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -599,52 +817,75 @@ def update( service_name: str, version_set_id: str, if_match: str, - parameters: "_models.ApiVersionSetUpdateParameters", + parameters: Union[_models.ApiVersionSetUpdateParameters, IO], **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Updates the details of the Api VersionSet specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiVersionSetContract] - _json = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -653,63 +894,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - version_set_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -720,5 +968,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # 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 index 7a6bc20bd498a..4eb627b3a5487 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,123 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, authsid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, authsid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,194 +171,190 @@ def build_create_or_update_request( authsid: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, authsid: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, authsid: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, authsid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class AuthorizationServerOperations(object): - """AuthorizationServerOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -350,38 +365,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.AuthorizationServerCollection"]: + ) -> Iterable["_models.AuthorizationServerContract"]: """Lists a collection of authorization servers defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationServerCollection or the result of + :return: An iterator like instance of either AuthorizationServerContract or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.AuthorizationServerCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -389,24 +413,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -420,7 +442,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,51 +454,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - authsid: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -483,55 +512,62 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - authsid: str, - **kwargs: Any - ) -> "_models.AuthorizationServerContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,17 +576,84 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -558,52 +661,75 @@ def create_or_update( resource_group_name: str, service_name: str, authsid: str, - parameters: "_models.AuthorizationServerContract", + parameters: Union[_models.AuthorizationServerContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Creates new authorization server or updates an existing authorization server. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'AuthorizationServerContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AuthorizationServerContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -613,22 +739,89 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationServerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -637,51 +830,75 @@ def update( service_name: str, authsid: str, if_match: str, - parameters: "_models.AuthorizationServerUpdateContract", + parameters: Union[_models.AuthorizationServerUpdateContract, IO], **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Updates the details of the authorization server specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: OAuth2 Server settings Update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerUpdateContract + :param parameters: OAuth2 Server settings Update parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AuthorizationServerUpdateContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -690,62 +907,69 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - authsid: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,48 +980,56 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace def list_secrets( - self, - resource_group_name: str, - service_name: str, - authsid: str, - **kwargs: Any - ) -> "_models.AuthorizationServerSecretsContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param authsid: Identifier of the authorization server. + :param authsid: Identifier of the authorization server. Required. :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationServerSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerSecretsContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AuthorizationServerSecretsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerSecretsContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthorizationServerSecretsContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,14 +1038,13 @@ def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AuthorizationServerSecretsContract', pipeline_response) + deserialized = self._deserialize("AuthorizationServerSecretsContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py index 3c0027e30913a..9c437e4c16431 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,123 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, backend_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, backend_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,203 +171,193 @@ def build_create_or_update_request( backend_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, backend_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, backend_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, backend_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class BackendOperations(object): - """BackendOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -359,36 +368,46 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.BackendCollection"]: + ) -> Iterable["_models.BackendContract"]: """Lists a collection of backends in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BackendCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.BackendCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -396,24 +415,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -427,7 +444,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -437,52 +456,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -491,56 +515,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - **kwargs: Any - ) -> "_models.BackendContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,17 +580,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('BackendContract', pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -567,53 +667,76 @@ def create_or_update( resource_group_name: str, service_name: str, backend_id: str, - parameters: "_models.BackendContract", + parameters: Union[_models.BackendContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Creates or Updates a backend. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.BackendContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendContract] - _json = self._serialize.body(parameters, 'BackendContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackendContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -623,22 +746,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('BackendContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('BackendContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -647,52 +839,75 @@ def update( service_name: str, backend_id: str, if_match: str, - parameters: "_models.BackendUpdateParameters", + parameters: Union[_models.BackendUpdateParameters, IO], **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Updates an existing backend. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.BackendUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackendContract] - _json = self._serialize.body(parameters, 'BackendUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -701,63 +916,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('BackendContract', pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -768,61 +990,148 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore + @overload + def reconnect( # pylint: disable=inconsistent-return-statements + 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 APIM proxy 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def reconnect( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the APIM proxy 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def reconnect( + def reconnect( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, backend_id: str, - parameters: Optional["_models.BackendReconnectContract"] = None, + parameters: Optional[Union[_models.BackendReconnectContract, IO]] = None, **kwargs: Any ) -> None: """Notifies the APIM proxy 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type backend_id: str - :param parameters: Reconnect request parameters. - :type parameters: ~api_management_client.models.BackendReconnectContract + :param parameters: Reconnect request parameters. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'BackendReconnectContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "BackendReconnectContract", is_xml=True) + 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, - template_url=self.reconnect.metadata['url'], + content=_content, + template_url=self.reconnect.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: @@ -833,5 +1142,4 @@ def reconnect( if cls: return cls(pipeline_response, None, {}) - reconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect'} # type: ignore - + reconnect.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect"} # 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 index 8d028e467c4b0..83d4e14e670a8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -36,111 +45,121 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, cache_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, cache_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -149,157 +168,151 @@ def build_create_or_update_request( cache_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, cache_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, cache_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class CacheOperations(object): - """CacheOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -309,53 +322,61 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.CacheCollection"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CacheCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.CacheCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -369,7 +390,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,52 +402,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + or valid Azure region identifier). Required. :type cache_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -433,56 +461,61 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - **kwargs: Any - ) -> "_models.CacheContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + or valid Azure region identifier). Required. :type cache_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CacheContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -491,17 +524,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CacheContract', pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # 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. + + :param resource_group_name: The name of the resource group. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. + :param resource_group_name: The name of the resource group. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -509,53 +611,76 @@ def create_or_update( resource_group_name: str, service_name: str, cache_id: str, - parameters: "_models.CacheContract", + parameters: Union[_models.CacheContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + or valid Azure region identifier). Required. :type cache_id: str - :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CacheContract + :param parameters: Create or Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CacheContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CacheContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CacheContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -565,22 +690,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CacheContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CacheContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CacheContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CacheContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CacheContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -589,52 +783,75 @@ def update( service_name: str, cache_id: str, if_match: str, - parameters: "_models.CacheUpdateParameters", + parameters: Union[_models.CacheUpdateParameters, IO], **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Updates the details of the cache specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.CacheUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CacheContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CacheUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CacheContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -643,63 +860,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CacheContract', pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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). + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -710,5 +934,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # 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 index 988459941cfce..52f960dcb226b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,115 +47,131 @@ def build_list_by_service_request( is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = _SERIALIZER.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, certificate_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, certificate_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -155,47 +180,50 @@ def build_create_or_update_request( certificate_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -207,94 +235,104 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, certificate_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class CertificateOperations(object): - """CertificateOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -306,41 +344,49 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.CertificateCollection"]: + ) -> Iterable["_models.CertificateContract"]: """Lists a collection of all certificates in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :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. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.CertificateCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -349,25 +395,22 @@ def prepare_request(next_link=None): top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -381,7 +424,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,52 +436,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -445,56 +495,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - **kwargs: Any - ) -> "_models.CertificateContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -503,17 +560,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CertificateContract', pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # 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. + + :param resource_group_name: The name of the resource group. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. + + :param resource_group_name: The name of the resource group. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -521,53 +647,76 @@ def create_or_update( resource_group_name: str, service_name: str, certificate_id: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """Creates or updates the certificate being used for authentication with the backend. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str - :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CertificateCreateOrUpdateParameters + :param parameters: Create or Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -577,68 +726,75 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CertificateContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('CertificateContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -649,49 +805,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace def refresh_secret( - self, - resource_group_name: str, - service_name: str, - certificate_id: str, - **kwargs: Any - ) -> "_models.CertificateContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateContract] - 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, - template_url=self.refresh_secret.metadata['url'], + api_version=api_version, + template_url=self.refresh_secret.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -700,14 +864,13 @@ def refresh_secret( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('CertificateContract', pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret'} # type: ignore - + refresh_secret.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py index e637bf6033b1d..402703e26f9e1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,62 +6,73 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, content_type_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_tag_request( @@ -71,35 +83,41 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -110,35 +128,41 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -151,37 +175,43 @@ def build_create_or_update_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -194,110 +224,118 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ContentItemOperations(object): - """ContentItemOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ContentItemCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContentItemCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ContentItemCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentItemCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -311,7 +349,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -321,56 +361,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :param content_item_id: Content item identifier. Required. :type content_item_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,59 +425,65 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - content_item_id: str, - **kwargs: Any - ) -> "_models.ContentItemContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :param content_item_id: Content item identifier. Required. :type content_item_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentItemContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentItemContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -440,17 +492,16 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ContentItemContract', pipeline_response) + deserialized = self._deserialize("ContentItemContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace def create_or_update( @@ -461,32 +512,39 @@ def create_or_update( content_item_id: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ContentItemContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :param content_item_id: Content item identifier. Required. :type content_item_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentItemContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentItemContract] - request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, @@ -494,12 +552,18 @@ def create_or_update( content_item_id=content_item_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -509,25 +573,24 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentItemContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentItemContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentItemContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentItemContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -538,29 +601,36 @@ def delete( ) -> None: """Removes the specified developer portal's content item. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str - :param content_item_id: Content item identifier. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -568,12 +638,18 @@ def delete( content_item_id=content_item_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -584,5 +660,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # 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 index ed923ccd88917..da4e435f62632 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, content_type_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -107,36 +122,42 @@ def build_create_or_update_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -148,105 +169,115 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ContentTypeOperations(object): - """ContentTypeOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.ContentTypeCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContentTypeCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ContentTypeCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentTypeCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -260,7 +291,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -270,52 +303,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - **kwargs: Any - ) -> "_models.ContentTypeContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentTypeContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContentTypeContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -324,17 +364,16 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ContentTypeContract', pipeline_response) + deserialized = self._deserialize("ContentTypeContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore @distributed_trace def create_or_update( @@ -344,44 +383,57 @@ def create_or_update( content_type_id: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ContentTypeContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :param content_type_id: Content type identifier. Required. :type content_type_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ContentTypeContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -391,69 +443,76 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentTypeContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentTypeContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ContentTypeContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ContentTypeContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param content_type_id: Content type identifier. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +523,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # 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 index 9e76c7575dde0..4f406a3637e98 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,281 +6,293 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class DelegationSettingsOperations(object): - """DelegationSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -288,51 +301,57 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalDelegationSettings": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalDelegationSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalDelegationSettings] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,66 +360,150 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore + + @overload + def update( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + if_match: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def update( + def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalDelegationSettings", + parameters: Union[_models.PortalDelegationSettings, IO], **kwargs: Any ) -> None: """Update Delegation settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update Delegation settings. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :param parameters: Update Delegation settings. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalDelegationSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalDelegationSettings", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -411,57 +514,141 @@ def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PortalDelegationSettings", + parameters: Union[_models.PortalDelegationSettings, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalDelegationSettings": + ) -> _models.PortalDelegationSettings: """Create or Update Delegation settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalDelegationSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalDelegationSettings] - _json = self._serialize.body(parameters, 'PortalDelegationSettings') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalDelegationSettings", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -469,51 +656,60 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace def list_secrets( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalSettingValidationKeyContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSettingValidationKeyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingValidationKeyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSettingValidationKeyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingValidationKeyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSettingValidationKeyContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,12 +717,11 @@ def list_secrets( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSettingValidationKeyContract', pipeline_response) + deserialized = self._deserialize("PortalSettingValidationKeyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py index 244b39f81a2fd..233ae3bcb9ed1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,187 +6,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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: - api_version = "2021-08-01" - accept = "application/json" + +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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") -def build_get_by_name_request( - service_name: str, - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}') + _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'), + "serviceName": _SERIALIZER.url( + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_purge_request_initial( - service_name: str, - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" +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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}') + _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'), + "serviceName": _SERIALIZER.url( + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class DeletedServicesOperations(object): - """DeletedServicesOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.DeletedServicesCollection"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DeletedServiceContract"]: """Lists all soft-deleted services available for undelete for the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedServicesCollection or the result of + :return: An iterator like instance of either DeletedServiceContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.DeletedServicesCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServicesCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedServicesCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -199,7 +213,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,47 +225,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices"} # type: ignore @distributed_trace - def get_by_name( - self, - service_name: str, - location: str, - **kwargs: Any - ) -> "_models.DeletedServiceContract": + 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. + :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. + :param location: The location of the deleted API Management service. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedServiceContract, or the result of cls(response) - :rtype: ~api_management_client.models.DeletedServiceContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DeletedServiceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedServiceContract] - request = build_get_by_name_request( service_name=service_name, - subscription_id=self._config.subscription_id, location=location, - template_url=self.get_by_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -257,69 +279,73 @@ def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore - + get_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore def _purge_initial( - self, - service_name: str, - location: str, - **kwargs: Any - ) -> Optional["_models.DeletedServiceContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeletedServiceContract"]] + self, service_name: str, location: str, **kwargs: Any + ) -> Optional[_models.DeletedServiceContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_purge_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeletedServiceContract]] + + request = build_purge_request( service_name=service_name, - subscription_id=self._config.subscription_id, location=location, - template_url=self._purge_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._purge_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: - deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _purge_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore - + _purge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore @distributed_trace - def begin_purge( - self, - service_name: str, - location: str, - **kwargs: Any - ) -> LROPoller["_models.DeletedServiceContract"]: + def begin_purge(self, service_name: str, location: str, **kwargs: Any) -> LROPoller[None]: """Purges Api Management Service (deletes it with no option to undelete). - :param service_name: The name of the API Management service. + :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. + :param location: The location of the deleted API Management service. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -331,44 +357,50 @@ def begin_purge( Retry-After header is present. :return: An instance of LROPoller that returns either DeletedServiceContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.DeletedServiceContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._purge_initial( + raw_result = self._purge_initial( # type: ignore service_name=service_name, location=location, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_purge.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + begin_purge.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # 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 index 57df7d136ed85..dfb84efe1d625 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,127 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, diagnostic_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, diagnostic_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,47 +175,50 @@ def build_create_or_update_request( diagnostic_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -202,45 +228,48 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -252,57 +281,63 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class DiagnosticOperations(object): - """DiagnosticOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -313,35 +348,44 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DiagnosticCollection"]: + ) -> Iterable["_models.DiagnosticContract"]: """Lists all diagnostics of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.DiagnosticCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -349,24 +393,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -380,7 +422,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -390,52 +434,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - diagnostic_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -444,56 +493,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - diagnostic_id: str, - **kwargs: Any - ) -> "_models.DiagnosticContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,17 +558,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -520,53 +645,76 @@ def create_or_update( resource_group_name: str, service_name: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + service instance. Required. :type diagnostic_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DiagnosticContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -576,22 +724,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -600,52 +817,75 @@ def update( service_name: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: Union[_models.DiagnosticContract, IO], **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Updates the details of the Diagnostic specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :param parameters: Diagnostic Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticContract] - _json = self._serialize.body(parameters, 'DiagnosticContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,63 +894,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('DiagnosticContract', pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - diagnostic_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -721,5 +968,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # 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 index b4951001138c7..97252d3c00bfc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,272 +46,296 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + template_name: Union[str, _models.TemplateName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "templateName": _SERIALIZER.url("template_name", template_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + template_name: Union[str, _models.TemplateName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "templateName": _SERIALIZER.url("template_name", template_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + template_name: Union[str, _models.TemplateName], subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "templateName": _SERIALIZER.url("template_name", template_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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"], + template_name: Union[str, _models.TemplateName], subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "templateName": _SERIALIZER.url("template_name", template_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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"], + template_name: Union[str, _models.TemplateName], subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "templateName": _SERIALIZER.url("template_name", template_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class EmailTemplateOperations(object): - """EmailTemplateOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -313,35 +346,45 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EmailTemplateCollection"]: + ) -> Iterable["_models.EmailTemplateContract"]: """Gets all email templates. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EmailTemplateCollection or the result of + :return: An iterator like instance of either EmailTemplateContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.EmailTemplateCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -349,24 +392,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -380,7 +421,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -390,51 +433,69 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates"} # type: ignore @distributed_trace def get_entity_tag( self, resource_group_name: str, service_name: str, - template_name: Union[str, "_models.TemplateName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,55 +504,73 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace def get( self, resource_group_name: str, service_name: str, - template_name: Union[str, "_models.TemplateName"], + template_name: Union[str, _models.TemplateName], **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Gets the details of the email template specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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 callable cls: A custom type or function that will be passed the direct response - :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: EmailTemplateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,70 +579,182 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.EmailTemplateUpdateParameters", + template_name: Union[str, _models.TemplateName], + parameters: Union[_models.EmailTemplateUpdateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates an Email Template. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName - :param parameters: Email Template update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: EmailTemplateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -572,71 +763,182 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + template_name: Union[str, _models.TemplateName], if_match: str, - parameters: "_models.EmailTemplateUpdateParameters", + parameters: Union[_models.EmailTemplateUpdateParameters, IO], **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates API Management email template. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: EmailTemplateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EmailTemplateContract] - _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -645,62 +947,81 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - template_name: Union[str, "_models.TemplateName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -711,5 +1032,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # 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 index d7901e83c4257..48e6f100d493e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,188 +47,189 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_id: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class GatewayApiOperations(object): - """GatewayApiOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -231,37 +241,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiCollection"]: + ) -> Iterable["_models.ApiContract"]: """Lists a collection of the APIs associated with a gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -270,25 +290,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -302,7 +319,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,56 +331,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -370,15 +396,83 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore + @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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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] = 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -387,39 +481,56 @@ def create_or_update( service_name: str, gateway_id: str, api_id: str, - parameters: Optional["_models.AssociationContract"] = None, + parameters: Optional[Union[_models.AssociationContract, IO]] = None, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Adds an API to the specified Gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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: - :type parameters: ~api_management_client.models.AssociationContract + :param parameters: Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if parameters is not None: - _json = self._serialize.body(parameters, 'AssociationContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "AssociationContract", is_xml=True) + else: + _json = None request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -427,14 +538,21 @@ def create_or_update( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -443,63 +561,71 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -510,5 +636,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # 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 index 60bdc569e4142..5f742a2e0b664 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,40 +47,46 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_tag_request( @@ -82,35 +97,43 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -121,35 +144,43 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -159,48 +190,51 @@ def build_create_or_update_request( certificate_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -213,58 +247,64 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class GatewayCertificateAuthorityOperations(object): - """GatewayCertificateAuthorityOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -276,39 +316,48 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GatewayCertificateAuthorityCollection"]: + ) -> Iterable["_models.GatewayCertificateAuthorityContract"]: """Lists the collection of Certificate Authorities for the specified Gateway entity. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | eq, ne | |
. + filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCertificateAuthorityCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayCertificateAuthorityContract or the result + of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.GatewayCertificateAuthorityCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCertificateAuthorityCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -317,25 +366,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -349,7 +395,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -359,57 +407,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,61 +472,67 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Management service instance. Required. :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayCertificateAuthorityContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCertificateAuthorityContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -481,17 +541,94 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -500,41 +637,57 @@ def create_or_update( service_name: str, gateway_id: str, certificate_id: str, - parameters: "_models.GatewayCertificateAuthorityContract", + parameters: Union[_models.GatewayCertificateAuthorityContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + ) -> _models.GatewayCertificateAuthorityContract: """Assign Certificate entity to Gateway entity as Certificate Authority. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Management service instance. Required. :type certificate_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayCertificateAuthorityContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayCertificateAuthorityContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCertificateAuthorityContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayCertificateAuthorityContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -542,15 +695,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -560,25 +720,24 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -589,31 +748,38 @@ def delete( ) -> None: """Remove relationship between Certificate Authority and Gateway entity. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -621,12 +787,18 @@ def delete( certificate_id=certificate_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -637,5 +809,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # 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 index e7a536356bf16..26108247681d5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,118 +47,126 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, hc_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, hc_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -159,48 +176,49 @@ def build_create_or_update_request( hc_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -213,58 +231,62 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class GatewayHostnameConfigurationOperations(object): - """GatewayHostnameConfigurationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -276,40 +298,50 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GatewayHostnameConfigurationCollection"]: + ) -> Iterable["_models.GatewayHostnameConfigurationContract"]: """Lists the collection of hostname configurations for the specified gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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 |
. + | 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the - result of cls(response) + :return: An iterator like instance of either GatewayHostnameConfigurationContract or the result + of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.GatewayHostnameConfigurationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayHostnameConfigurationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -318,25 +350,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -350,7 +379,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -360,58 +391,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Gateway entity. Required. :type hc_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -420,61 +457,67 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Gateway entity. Required. :type hc_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayHostnameConfigurationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayHostnameConfigurationContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -483,17 +526,94 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -502,41 +622,57 @@ def create_or_update( service_name: str, gateway_id: str, hc_id: str, - parameters: "_models.GatewayHostnameConfigurationContract", + parameters: Union[_models.GatewayHostnameConfigurationContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + ) -> _models.GatewayHostnameConfigurationContract: """Creates of updates hostname configuration for a Gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + Gateway entity. Required. :type hc_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayHostnameConfigurationContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayHostnameConfigurationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayHostnameConfigurationContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayHostnameConfigurationContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -544,15 +680,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -562,60 +705,60 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -623,12 +766,18 @@ def delete( hc_id=hc_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -639,5 +788,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # 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 index 784480f5d4c56..9fc5f5dda8b27 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,123 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,286 +171,274 @@ def build_create_or_update_request( gateway_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class GatewayOperations(object): - """GatewayOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -442,37 +449,46 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GatewayCollection"]: + ) -> Iterable["_models.GatewayContract"]: """Lists a collection of gateways registered with service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GatewayCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GatewayCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -480,24 +496,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -511,7 +525,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,52 +537,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -575,56 +596,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - **kwargs: Any - ) -> "_models.GatewayContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -633,17 +661,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayContract', pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -651,53 +748,76 @@ def create_or_update( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayContract", + parameters: Union[_models.GatewayContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Creates or updates a Gateway to be used in Api Management instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayContract] - _json = self._serialize.body(parameters, 'GatewayContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -707,22 +827,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GatewayContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GatewayContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -731,52 +920,75 @@ def update( service_name: str, gateway_id: str, if_match: str, - parameters: "_models.GatewayContract", + parameters: Union[_models.GatewayContract, IO], **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Updates the details of the gateway specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayContract] - _json = self._serialize.body(parameters, 'GatewayContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayContract", is_xml=True) request = build_update_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, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,63 +997,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayContract', pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -852,49 +1071,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - **kwargs: Any - ) -> "_models.GatewayKeysContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayKeysContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayKeysContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayKeysContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayKeysContract] - 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, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -903,66 +1130,150 @@ def list_keys( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GatewayKeysContract', pipeline_response) + deserialized = self._deserialize("GatewayKeysContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys"} # type: ignore + + @overload + def regenerate_key( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def regenerate_key( + def regenerate_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayKeyRegenerationRequestContract", + parameters: Union[_models.GatewayKeyRegenerationRequestContract, IO], **kwargs: Any ) -> None: """Regenerates specified gateway key invalidating any tokens created with it. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayKeyRegenerationRequestContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -973,8 +1284,69 @@ def regenerate_key( if cls: return cls(pipeline_response, None, {}) - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey'} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayTokenContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def generate_token( @@ -982,48 +1354,71 @@ def generate_token( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayTokenRequestContract", + parameters: Union[_models.GatewayTokenRequestContract, IO], **kwargs: Any - ) -> "_models.GatewayTokenContract": + ) -> _models.GatewayTokenContract: """Gets the Shared Access Authorization Token for the gateway. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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'. + service instance. Must not have value 'managed'. Required. :type gateway_id: str - :param parameters: - :type parameters: ~api_management_client.models.GatewayTokenRequestContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewayTokenContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayTokenContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GatewayTokenContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayTokenContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GatewayTokenRequestContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GatewayTokenContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.generate_token.metadata['url'], + content=_content, + template_url=self.generate_token.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1031,12 +1426,11 @@ def generate_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewayTokenContract', pipeline_response) + deserialized = self._deserialize("GatewayTokenContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken'} # type: ignore - + generate_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py index 4f77dca140ca0..587d13c3218fb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,30 +6,38 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,224 +48,233 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, schema_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, schema_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, service_name: str, schema_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, schema_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class GlobalSchemaOperations(object): - """GlobalSchemaOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -267,35 +285,45 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GlobalSchemaCollection"]: + ) -> Iterable["_models.GlobalSchemaContract"]: """Lists a collection of schemas registered with service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GlobalSchemaCollection or the result of + :return: An iterator like instance of either GlobalSchemaContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GlobalSchemaCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GlobalSchemaCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -303,24 +331,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -334,7 +360,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,52 +372,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - schema_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,56 +431,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - schema_id: str, - **kwargs: Any - ) -> "_models.GlobalSchemaContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GlobalSchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.GlobalSchemaContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GlobalSchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GlobalSchemaContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -456,76 +496,181 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: Union[_models.GlobalSchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.GlobalSchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GlobalSchemaContract"]] + ) -> Optional[_models.GlobalSchemaContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GlobalSchemaContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GlobalSchemaContract]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GlobalSchemaContract", is_xml=True) + + 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -533,24 +678,27 @@ def begin_create_or_update( resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: Union[_models.GlobalSchemaContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.GlobalSchemaContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type schema_id: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.GlobalSchemaContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -561,101 +709,116 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either GlobalSchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.GlobalSchemaContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GlobalSchemaContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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('GlobalSchemaContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - schema_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -666,5 +829,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # 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 index bc36b3954f2ec..37a041b569ccb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,123 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,157 +171,151 @@ def build_create_or_update_request( group_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, group_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, group_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class GroupOperations(object): - """GroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -313,37 +326,46 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GroupCollection"]: + ) -> Iterable["_models.GroupContract"]: """Lists a collection of groups defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + endswith |
| externalId | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GroupCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -351,24 +373,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +402,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,52 +414,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - group_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -446,56 +473,61 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -504,17 +536,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -522,53 +623,76 @@ def create_or_update( resource_group_name: str, service_name: str, group_id: str, - parameters: "_models.GroupCreateParameters", + parameters: Union[_models.GroupCreateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Creates or Updates a group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.GroupCreateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GroupCreateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -578,22 +702,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GroupContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('GroupContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -602,52 +795,75 @@ def update( service_name: str, group_id: str, if_match: str, - parameters: "_models.GroupUpdateParameters", + parameters: Union[_models.GroupUpdateParameters, IO], **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Updates the details of the group specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.GroupUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GroupUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,63 +872,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - group_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -723,5 +946,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # 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 index 76fb5f0a13974..aabb33cdbb443 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,179 +47,186 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, group_id: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, group_id: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, group_id: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class GroupUserOperations(object): - """GroupUserOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -221,15 +238,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.UserCollection"]: + ) -> Iterable["_models.UserContract"]: """Lists a collection of user entities associated with the group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type group_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -238,25 +255,34 @@ def list( 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 |
. + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.UserCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -265,25 +291,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -297,7 +320,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,56 +332,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users"} # type: ignore @distributed_trace def check_entity_exists( - self, - resource_group_name: str, - service_name: str, - group_id: str, - user_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -368,53 +400,61 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace def create( - self, - resource_group_name: str, - service_name: str, - group_id: str, - user_id: str, - **kwargs: Any - ) -> "_models.UserContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] - 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, - template_url=self.create.metadata['url'], + api_version=api_version, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -423,63 +463,71 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - group_id: str, - user_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -490,5 +538,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # 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 index 8270aa523bf16..cf829290546e2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,378 +6,420 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + identity_provider_name: Union[str, _models.IdentityProviderType], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + identity_provider_name: Union[str, _models.IdentityProviderType], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + identity_provider_name: Union[str, _models.IdentityProviderType], subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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"], + identity_provider_name: Union[str, _models.IdentityProviderType], subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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"], + identity_provider_name: Union[str, _models.IdentityProviderType], subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + identity_provider_name: Union[str, _models.IdentityProviderType], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class IdentityProviderOperations(object): - """IdentityProviderOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.IdentityProviderList"]: + 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. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IdentityProviderList or the result of + :return: An iterator like instance of either IdentityProviderContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IdentityProviderList] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -390,7 +433,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -400,51 +445,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders"} # type: ignore @distributed_trace def get_entity_tag( self, resource_group_name: str, service_name: str, - identity_provider_name: Union[str, "_models.IdentityProviderType"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -453,56 +510,68 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace def get( self, resource_group_name: str, service_name: str, - identity_provider_name: Union[str, "_models.IdentityProviderType"], + identity_provider_name: Union[str, _models.IdentityProviderType], **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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 callable cls: A custom type or function that will be passed the direct response - :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IdentityProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -511,70 +580,163 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.IdentityProviderCreateContract", + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: Union[_models.IdentityProviderCreateContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Creates or Updates the IdentityProvider configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IdentityProviderCreateContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IdentityProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'IdentityProviderCreateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IdentityProviderCreateContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -584,75 +746,168 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + identity_provider_name: Union[str, _models.IdentityProviderType], if_match: str, - parameters: "_models.IdentityProviderUpdateParameters", + parameters: Union[_models.IdentityProviderUpdateParameters, IO], **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Updates an existing IdentityProvider configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IdentityProviderUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IdentityProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IdentityProviderContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -661,62 +916,75 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - identity_provider_name: Union[str, "_models.IdentityProviderType"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -727,48 +995,61 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace def list_secrets( self, resource_group_name: str, service_name: str, - identity_provider_name: Union[str, "_models.IdentityProviderType"], + identity_provider_name: Union[str, _models.IdentityProviderType], **kwargs: Any - ) -> "_models.ClientSecretContract": + ) -> _models.ClientSecretContract: """Gets the client secret details of the Identity Provider. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :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 callable cls: A custom type or function that will be passed the direct response - :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ClientSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientSecretContract] - 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, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -777,14 +1058,13 @@ def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ClientSecretContract', pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py index 7f1d97aacc248..17aa08e85c698 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -36,98 +46,106 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, issue_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class IssueOperations(object): - """IssueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -138,12 +156,12 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueCollection"]: + ) -> Iterable["_models.IssueContract"]: """Lists a collection of issues in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -152,25 +170,34 @@ def list_by_service( 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 | |
. + endswith |
| state | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -178,24 +205,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -209,7 +234,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -219,52 +246,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - issue_id: str, - **kwargs: Any - ) -> "_models.IssueContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type issue_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: IssueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IssueContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, issue_id=issue_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -273,14 +305,13 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('IssueContract', pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py index 7c176f5759944..2cfb5c3c5ac25 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,123 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, logger_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, logger_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,157 +171,151 @@ def build_create_or_update_request( logger_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, logger_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, logger_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class LoggerOperations(object): - """LoggerOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -313,37 +326,46 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.LoggerCollection"]: + ) -> Iterable["_models.LoggerContract"]: """Lists a collection of loggers in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 |
. + substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LoggerCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.LoggerCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -351,24 +373,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +402,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,51 +414,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - logger_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -445,55 +473,61 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - logger_id: str, - **kwargs: Any - ) -> "_models.LoggerContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,17 +536,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LoggerContract', pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -520,52 +623,76 @@ def create_or_update( resource_group_name: str, service_name: str, logger_id: str, - parameters: "_models.LoggerContract", + parameters: Union[_models.LoggerContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Creates or Updates a logger. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.LoggerContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'LoggerContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LoggerContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -575,22 +702,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('LoggerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('LoggerContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -599,51 +795,75 @@ def update( service_name: str, logger_id: str, if_match: str, - parameters: "_models.LoggerUpdateContract", + parameters: Union[_models.LoggerUpdateContract, IO], **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Updates an existing logger. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.LoggerUpdateContract + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'LoggerUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LoggerContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,62 +872,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LoggerContract', pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - logger_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -718,5 +946,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # 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 index 9392f40884fd6..3aff94183ec3d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,30 +6,38 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -40,212 +49,234 @@ def build_list_by_service_request( is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = _SERIALIZER.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, named_value_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, named_value_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, service_name: str, named_value_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( +def build_update_request( resource_group_name: str, service_name: str, named_value_id: str, subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -257,131 +288,145 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, named_value_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_refresh_secret_request_initial( - resource_group_name: str, - service_name: str, - named_value_id: str, - subscription_id: str, - **kwargs: Any +def build_refresh_secret_request( + resource_group_name: str, service_name: str, named_value_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class NamedValueOperations(object): - """NamedValueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -393,40 +438,48 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.NamedValueCollection"]: + ) -> Iterable["_models.NamedValueContract"]: """Lists a collection of named values defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :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. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamedValueCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.NamedValueCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -435,25 +488,22 @@ def prepare_request(next_link=None): top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -467,7 +517,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,51 +529,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -530,55 +587,62 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - **kwargs: Any - ) -> "_models.NamedValueContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamedValueContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NamedValueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -587,76 +651,179 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('NamedValueContract', pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: Union[_models.NamedValueCreateContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'NamedValueCreateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamedValueContract]] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueCreateContract", is_xml=True) + + 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, - if_match=if_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -664,23 +831,26 @@ def begin_create_or_update( resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: Union[_models.NamedValueCreateContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.NamedValueContract"]: + ) -> LROPoller[_models.NamedValueContract]: """Creates or updates named value. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.NamedValueCreateContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -691,55 +861,62 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.NamedValueContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore def _update_initial( self, @@ -747,53 +924,157 @@ def _update_initial( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: Union[_models.NamedValueUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'NamedValueUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamedValueContract]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueUpdateParameters") - request = build_update_request_initial( + 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -802,22 +1083,25 @@ def begin_update( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: Union[_models.NamedValueUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.NamedValueContract"]: + ) -> LROPoller[_models.NamedValueContract]: """Updates the specific named value. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.NamedValueUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -828,100 +1112,115 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.NamedValueContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -932,48 +1231,56 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace def list_value( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - **kwargs: Any - ) -> "_models.NamedValueSecretContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamedValueSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueSecretContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NamedValueSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueSecretContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueSecretContract] - 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, - template_url=self.list_value.metadata['url'], + api_version=api_version, + template_url=self.list_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,79 +1289,83 @@ def list_value( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('NamedValueSecretContract', pipeline_response) + deserialized = self._deserialize("NamedValueSecretContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_value.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue'} # type: ignore - + list_value.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue"} # type: ignore def _refresh_secret_initial( - self, - resource_group_name: str, - service_name: str, - named_value_id: str, - **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + self, resource_group_name: str, service_name: str, named_value_id: str, **kwargs: Any + ) -> Optional[_models.NamedValueContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_refresh_secret_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamedValueContract]] + + 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, - template_url=self._refresh_secret_initial.metadata['url'], + api_version=api_version, + template_url=self._refresh_secret_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('NamedValueContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _refresh_secret_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore - + _refresh_secret_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # 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"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param named_value_id: Identifier of the NamedValue. + :param named_value_id: Identifier of the NamedValue. Required. :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1066,48 +1377,55 @@ def begin_refresh_secret( Retry-After header is present. :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.NamedValueContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._refresh_secret_initial( + raw_result = self._refresh_secret_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore + begin_refresh_secret.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # 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 index e08388461e8de..bb3bbaecc89db 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,156 +6,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus') + _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'), - "serviceName": _SERIALIZER.url("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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_location_request( - subscription_id: str, - resource_group_name: str, - service_name: str, - location_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, location_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class NetworkStatusOperations(object): - """NetworkStatusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of NetworkStatusContractByLocation, or the result of cls(response) - :rtype: list[~api_management_client.models.NetworkStatusContractByLocation] - :raises: ~azure.core.exceptions.HttpResponseError + :return: list of NetworkStatusContractByLocation or the result of cls(response) + :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.NetworkStatusContractByLocation"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.NetworkStatusContractByLocation]] - request = build_list_by_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - template_url=self.list_by_service.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,58 +184,66 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[NetworkStatusContractByLocation]', pipeline_response) + deserialized = self._deserialize("[NetworkStatusContractByLocation]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus"} # type: ignore @distributed_trace def list_by_location( - self, - resource_group_name: str, - service_name: str, - location_name: str, - **kwargs: Any - ) -> "_models.NetworkStatusContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + the Azure Regions like West US, East US, South Central US. Required. :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkStatusContract, or the result of cls(response) - :rtype: ~api_management_client.models.NetworkStatusContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NetworkStatusContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkStatusContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkStatusContract] - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, location_name=location_name, - template_url=self.list_by_location.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -221,12 +251,11 @@ def list_by_location( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkStatusContract', pipeline_response) + deserialized = self._deserialize("NetworkStatusContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus'} # type: ignore - + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py index eb180a16c320f..2ec7065479c3d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -35,137 +45,153 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class NotificationOperations(object): - """NotificationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -175,54 +201,62 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.NotificationCollection"]: + ) -> Iterable["_models.NotificationContract"]: """Lists a collection of properties defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotificationCollection or the result of + :return: An iterator like instance of either NotificationContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.NotificationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -236,7 +270,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,51 +282,65 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications"} # type: ignore @distributed_trace def get( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Gets the details of the Notification specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 callable cls: A custom type or function that will be passed the direct response - :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -298,60 +348,75 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotificationContract', pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore @distributed_trace def create_or_update( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Create or Update API Management publisher notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -359,12 +424,11 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotificationContract', pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py index 4e6a042c0b928..5d16ab0353bc3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,240 +6,286 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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"], + notification_name: Union[str, _models.NotificationName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], email: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], email: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], email: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class NotificationRecipientEmailOperations(object): - """NotificationRecipientEmailOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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"], + notification_name: Union[str, _models.NotificationName], **kwargs: Any - ) -> "_models.RecipientEmailCollection": + ) -> _models.RecipientEmailCollection: """Gets the list of the Notification Recipient Emails subscribed to a notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 callable cls: A custom type or function that will be passed the direct response - :return: RecipientEmailCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientEmailCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientEmailCollection] - 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, - template_url=self.list_by_notification.metadata['url'], + api_version=api_version, + template_url=self.list_by_notification.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,59 +293,74 @@ def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RecipientEmailCollection', pipeline_response) + deserialized = self._deserialize("RecipientEmailCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails'} # type: ignore - + list_by_notification.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails"} # type: ignore @distributed_trace def check_entity_exists( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName - :param email: Email identifier. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -310,52 +372,67 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace def create_or_update( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], email: str, **kwargs: Any - ) -> "_models.RecipientEmailContract": + ) -> _models.RecipientEmailContract: """Adds the Email address to the list of Recipients for the Notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName - :param email: Email identifier. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecipientEmailContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientEmailContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientEmailContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -364,62 +441,77 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('RecipientEmailContract', pipeline_response) + deserialized = self._deserialize("RecipientEmailContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('RecipientEmailContract', pipeline_response) + deserialized = self._deserialize("RecipientEmailContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName - :param email: Email identifier. + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -430,5 +522,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # 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 index af00d3806ca91..53815a33e44a6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,240 +6,286 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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"], + notification_name: Union[str, _models.NotificationName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + notification_name: Union[str, _models.NotificationName], user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class NotificationRecipientUserOperations(object): - """NotificationRecipientUserOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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"], + notification_name: Union[str, _models.NotificationName], **kwargs: Any - ) -> "_models.RecipientUserCollection": + ) -> _models.RecipientUserCollection: """Gets the list of the Notification Recipient User subscribed to the notification. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 callable cls: A custom type or function that will be passed the direct response - :return: RecipientUserCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientUserCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientUserCollection] - 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, - template_url=self.list_by_notification.metadata['url'], + api_version=api_version, + template_url=self.list_by_notification.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,59 +293,75 @@ def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RecipientUserCollection', pipeline_response) + deserialized = self._deserialize("RecipientUserCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers'} # type: ignore - + list_by_notification.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers"} # type: ignore @distributed_trace def check_entity_exists( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -310,52 +373,68 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace def create_or_update( self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + notification_name: Union[str, _models.NotificationName], user_id: str, **kwargs: Any - ) -> "_models.RecipientUserContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecipientUserContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: RecipientUserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecipientUserContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -364,62 +443,78 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('RecipientUserContract', pipeline_response) + deserialized = self._deserialize("RecipientUserContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('RecipientUserContract', pipeline_response) + deserialized = self._deserialize("RecipientUserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - notification_name: Union[str, "_models.NotificationName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -430,5 +525,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # 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 index 18d7fc5d62910..b5d97ab5e8d89 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,123 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, opid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, opid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,194 +171,190 @@ def build_create_or_update_request( opid: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, opid: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, opid: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, opid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class OpenIdConnectProviderOperations(object): - """OpenIdConnectProviderOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -350,38 +365,47 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.OpenIdConnectProviderCollection"]: + ) -> Iterable["_models.OpenidConnectProviderContract"]: """Lists of all the OpenId Connect Providers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of + :return: An iterator like instance of either OpenidConnectProviderContract or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.OpenIdConnectProviderCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenIdConnectProviderCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenIdConnectProviderCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -389,24 +413,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -420,7 +442,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,51 +454,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - opid: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -483,55 +512,62 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - opid: str, - **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OpenidConnectProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenidConnectProviderContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,17 +576,84 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -558,52 +661,75 @@ def create_or_update( resource_group_name: str, service_name: str, opid: str, - parameters: "_models.OpenidConnectProviderContract", + parameters: Union[_models.OpenidConnectProviderContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Creates or updates the OpenID Connect Provider. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderContract + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OpenidConnectProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'OpenidConnectProviderContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenidConnectProviderContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenidConnectProviderContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -613,22 +739,89 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenidConnectProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -637,51 +830,74 @@ def update( service_name: str, opid: str, if_match: str, - parameters: "_models.OpenidConnectProviderUpdateContract", + parameters: Union[_models.OpenidConnectProviderUpdateContract, IO], **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Updates the specific OpenID Connect Provider. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderUpdateContract + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: OpenidConnectProviderContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OpenidConnectProviderContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -690,62 +906,69 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - opid: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,48 +979,56 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace def list_secrets( - self, - resource_group_name: str, - service_name: str, - opid: str, - **kwargs: Any - ) -> "_models.ClientSecretContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. + :param opid: Identifier of the OpenID Connect Provider. Required. :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ClientSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientSecretContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,14 +1037,13 @@ def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ClientSecretContract', pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py index 009fc1d9d6c34..ce3b0c16893b9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,64 +48,70 @@ def build_list_by_tags_request( include_not_tagged_operations: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if include_not_tagged_operations is not None: - query_parameters['includeNotTaggedOperations'] = _SERIALIZER.query("include_not_tagged_operations", include_not_tagged_operations, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class OperationOperations(object): - """OperationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -108,15 +124,15 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_operations: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable["_models.TagResourceContract"]: """Lists a collection of operations associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 | @@ -126,28 +142,36 @@ def list_by_tags( |
| 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 |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_operations: Include not tagged Operations. + :param include_not_tagged_operations: Include not tagged Operations. Default value is None. :type include_not_tagged_operations: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -157,26 +181,22 @@ def prepare_request(next_link=None): top=top, skip=skip, include_not_tagged_operations=include_not_tagged_operations, - template_url=self.list_by_tags.metadata['url'], + api_version=api_version, + template_url=self.list_by_tags.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -190,7 +210,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,8 +222,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags'} # type: ignore + list_by_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py index 628cccd96107f..bd67ba76a032a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,117 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints') + _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'), - "serviceName": _SERIALIZER.url("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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class OutboundNetworkDependenciesEndpointsOperations(object): - """OutboundNetworkDependenciesEndpointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OutboundNetworkDependenciesEndpointsOperations: + """ + .. 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OutboundEnvironmentEndpointList, or the result of cls(response) - :rtype: ~api_management_client.models.OutboundEnvironmentEndpointList - :raises: ~azure.core.exceptions.HttpResponseError + :return: OutboundEnvironmentEndpointList or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEnvironmentEndpointList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OutboundEnvironmentEndpointList] - request = build_list_by_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - template_url=self.list_by_service.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,12 +143,11 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OutboundEnvironmentEndpointList', pipeline_response) + deserialized = self._deserialize("OutboundEnvironmentEndpointList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints"} # 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 new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""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 + + +def patch_sdk(): + """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/operations/_policy_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py index 403985c5cb006..66c37cebd799b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,125 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, + scope: Optional[Union[str, _models.PolicyScopeContract]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if scope is not None: - query_parameters['scope'] = _SERIALIZER.query("scope", scope, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["scope"] = _SERIALIZER.query("scope", scope, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PolicyDescriptionOperations(object): - """PolicyDescriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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, + scope: Optional[Union[str, _models.PolicyScopeContract]] = None, **kwargs: Any - ) -> "_models.PolicyDescriptionCollection": + ) -> _models.PolicyDescriptionCollection: """Lists all policy descriptions. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param scope: Policy scope. - :type scope: str or ~api_management_client.models.PolicyScopeContract + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDescriptionCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyDescriptionCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyDescriptionCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDescriptionCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDescriptionCollection] - request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, scope=scope, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -131,12 +158,11 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDescriptionCollection', pipeline_response) + deserialized = self._deserialize("PolicyDescriptionCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py index 10288c26e03db..5dff849ab8d17 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,285 +6,320 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PolicyOperations(object): - """PolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.PolicyCollection": + def list_by_service(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.PolicyCollection: """Lists all the Global Policy definitions of the Api Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -291,56 +327,64 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - policy_id: Union[str, "_models.PolicyIdName"], - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,59 +393,71 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace def get( self, resource_group_name: str, service_name: str, - policy_id: Union[str, "_models.PolicyIdName"], - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the Global policy definition of the Api Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,70 +466,160 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PolicyContract', pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates the global policy configuration of the Api Management service. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - _json = self._serialize.body(parameters, 'PolicyContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -483,67 +629,79 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -554,5 +712,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py index 0c74736303479..6216fde670b81 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,30 +6,38 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,229 +48,242 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, portal_revision_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, portal_revision_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - service_name: str, - portal_revision_id: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, service_name: str, portal_revision_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( +def build_update_request( resource_group_name: str, service_name: str, portal_revision_id: str, subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class PortalRevisionOperations(object): - """PortalRevisionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -272,12 +294,12 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.PortalRevisionCollection"]: + ) -> Iterable["_models.PortalRevisionContract"]: """Lists developer portal's revisions. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: .. list-table:: :header-rows: 1 @@ -290,26 +312,35 @@ def list_by_service( |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 | |. + |isCurrent | eq, ne | |. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PortalRevisionCollection or the result of + :return: An iterator like instance of either PortalRevisionContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.PortalRevisionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -317,24 +348,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -348,7 +377,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,52 +389,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type portal_revision_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -412,56 +450,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - **kwargs: Any - ) -> "_models.PortalRevisionContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type portal_revision_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalRevisionContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalRevisionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalRevisionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -470,69 +515,168 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalRevisionContract', pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PortalRevisionContract]] - _json = self._serialize.body(parameters, 'PortalRevisionContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalRevisionContract", is_xml=True) - request = build_create_or_update_request_initial( + 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, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PortalRevisionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -540,21 +684,24 @@ def begin_create_or_update( resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> LROPoller["_models.PortalRevisionContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + Management service instance. Required. :type portal_revision_id: str - :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -565,54 +712,61 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either PortalRevisionContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.PortalRevisionContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore def _update_initial( self, @@ -620,53 +774,159 @@ def _update_initial( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PortalRevisionContract]] - _json = self._serialize.body(parameters, 'PortalRevisionContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalRevisionContract", is_xml=True) - request = build_update_request_initial( + 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PortalRevisionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -675,23 +935,26 @@ def begin_update( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: Union[_models.PortalRevisionContract, IO], **kwargs: Any - ) -> LROPoller["_models.PortalRevisionContract"]: + ) -> LROPoller[_models.PortalRevisionContract]: """Updates the description of specified portal revision or makes it current. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -702,52 +965,59 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either PortalRevisionContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.PortalRevisionContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + 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) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PortalRevisionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # 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 index 8bb66776b1a38..cb24ba5404491 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,117 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PortalSettingsOperations(object): - """PortalSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSettingsCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingsCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSettingsCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSettingsCollection] - request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,12 +143,11 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSettingsCollection', pipeline_response) + deserialized = self._deserialize("PortalSettingsCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings'} # type: ignore - + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py index 02b1d94345e43..2683552e0a3c0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,63 +6,74 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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( - subscription_id: str, - resource_group_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections') + _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'), - "serviceName": _SERIALIZER.url("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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_name_request( @@ -71,259 +83,293 @@ def build_get_by_name_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - resource_group_name: str, - subscription_id: str, - service_name: str, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources') + _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'), - "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])?$'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_private_link_resource_request( resource_group_name: str, - subscription_id: str, service_name: str, private_link_sub_resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}') + _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'), - "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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionOperations(object): - """PrivateEndpointConnectionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.PrivateEndpointConnectionListResult"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_service_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, - template_url=self.list_by_service.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - service_name=service_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -337,7 +383,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,51 +395,58 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get_by_name( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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, - template_url=self.get_by_name.metadata['url'], + api_version=api_version, + template_url=self.get_by_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,64 +454,162 @@ def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, - private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO], **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] - _json = self._serialize.body(private_endpoint_connection_request, 'PrivateEndpointConnectionRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection_request, (IO, bytes)): + _content = private_endpoint_connection_request + else: + _json = self._serialize.body(private_endpoint_connection_request, "PrivateEndpointConnectionRequest") - request = build_create_or_update_request_initial( + 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, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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( @@ -464,20 +617,23 @@ def begin_create_or_update( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, - private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Creates a new Private Endpoint Connection or updates an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: + :param private_endpoint_connection_request: Is either a model type or a IO type. Required. :type private_endpoint_connection_request: - ~api_management_client.models.PrivateEndpointConnectionRequest + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -488,104 +644,114 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + 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, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -597,80 +763,95 @@ def begin_delete( Retry-After header is present. :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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": - """Description for Gets the 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_private_link_resources_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, service_name=service_name, - template_url=self.list_private_link_resources.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,55 +859,63 @@ def list_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources'} # type: ignore - + list_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources"} # 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": - """Description for Gets the private link resources. + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param private_link_sub_resource_name: Name of the private link resource. Required. :type private_link_sub_resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_private_link_resource_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, service_name=service_name, private_link_sub_resource_name=private_link_sub_resource_name, - template_url=self.get_private_link_resource.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -734,12 +923,11 @@ def get_private_link_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_private_link_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}'} # type: ignore - + get_private_link_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py index 11167ec108afb..b7b6c07dd9e04 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,179 +47,186 @@ def build_list_by_product_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, api_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ProductApiOperations(object): - """ProductApiOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -221,15 +238,15 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiCollection"]: + ) -> Iterable["_models.ApiContract"]: """Lists a collection of the APIs associated with a product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -238,25 +255,34 @@ def list_by_product( |
| 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 |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -265,25 +291,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -297,7 +320,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,57 +332,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis"} # type: ignore @distributed_trace def check_entity_exists( - self, - resource_group_name: str, - service_name: str, - product_id: str, - api_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -369,54 +400,61 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @distributed_trace def create_or_update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - api_id: str, - **kwargs: Any - ) -> "_models.ApiContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApiContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -425,64 +463,71 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApiContract', pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - product_id: str, - api_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -493,5 +538,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py index 210babc16865f..f26edcda6ef22 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,179 +47,186 @@ def build_list_by_product_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ProductGroupOperations(object): - """ProductGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -221,38 +238,47 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GroupCollection"]: + ) -> Iterable["_models.GroupContract"]: """Lists the collection of developer groups associated with the specified product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 | |
. + description | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GroupCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -261,25 +287,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -293,7 +316,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,57 +328,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups"} # type: ignore @distributed_trace def check_entity_exists( - self, - resource_group_name: str, - service_name: str, - product_id: str, - group_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param group_id: Group identifier. Must be unique in the current API Management service - instance. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.check_entity_exists.metadata['url'], + api_version=api_version, + template_url=self.check_entity_exists.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -365,54 +396,61 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore - + check_entity_exists.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @distributed_trace def create_or_update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param group_id: Group identifier. Must be unique in the current API Management service - instance. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupContract] - 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, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -421,64 +459,71 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GroupContract', pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - product_id: str, - group_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param group_id: Group identifier. Must be unique in the current API Management service - instance. + instance. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -489,5 +534,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # 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 index 1033fc00cb012..7bc6ac758bc23 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,117 +48,127 @@ def build_list_by_service_request( tags: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if expand_groups is not None: - query_parameters['expandGroups'] = _SERIALIZER.query("expand_groups", expand_groups, 'bool') + _params["expandGroups"] = _SERIALIZER.query("expand_groups", expand_groups, "bool") if tags is not None: - query_parameters['tags'] = _SERIALIZER.query("tags", tags, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -158,95 +177,91 @@ def build_create_or_update_request( product_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, product_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -259,37 +274,43 @@ def build_delete_request( delete_subscriptions: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["deleteSubscriptions"] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_tags_request( @@ -303,63 +324,69 @@ def build_list_by_tags_request( include_not_tagged_products: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if include_not_tagged_products is not None: - query_parameters['includeNotTaggedProducts'] = _SERIALIZER.query("include_not_tagged_products", include_not_tagged_products, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ProductOperations(object): - """ProductOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -372,12 +399,12 @@ def list_by_service( expand_groups: Optional[bool] = None, tags: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ProductCollection"]: + ) -> Iterable["_models.ProductContract"]: """Lists a collection of products in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -385,30 +412,40 @@ def list_by_service( 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 | | |
. + endswith |
| state | filter | eq | |
| groups | expand | | |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :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. + 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. + :param tags: Products which are part of a specific tag. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ProductCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -418,26 +455,22 @@ def prepare_request(next_link=None): skip=skip, expand_groups=expand_groups, tags=tags, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -451,7 +484,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -461,52 +496,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - product_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -515,56 +555,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - product_id: str, - **kwargs: Any - ) -> "_models.ProductContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -573,17 +620,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ProductContract', pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -591,53 +707,76 @@ def create_or_update( resource_group_name: str, service_name: str, product_id: str, - parameters: "_models.ProductContract", + parameters: Union[_models.ProductContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Creates or Updates a product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ProductContract + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ProductContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductContract", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -647,22 +786,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ProductContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('ProductContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -671,52 +879,75 @@ def update( service_name: str, product_id: str, if_match: str, - parameters: "_models.ProductUpdateParameters", + parameters: Union[_models.ProductUpdateParameters, IO], **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Update existing product details. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ProductUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProductContract] - _json = self._serialize.body(parameters, 'ProductUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -725,20 +956,19 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ProductContract', pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -749,30 +979,38 @@ def delete( ) -> None: """Delete product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -780,12 +1018,18 @@ def delete( subscription_id=self._config.subscription_id, if_match=if_match, delete_subscriptions=delete_subscriptions, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -796,8 +1040,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace def list_by_tags( @@ -809,12 +1052,12 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_products: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable["_models.TagResourceContract"]: """Lists a collection of products associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -823,27 +1066,36 @@ def list_by_tags( |
| 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_products: Include not tagged Products. + :param include_not_tagged_products: Include not tagged Products. Default value is None. :type include_not_tagged_products: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -852,25 +1104,22 @@ def prepare_request(next_link=None): top=top, skip=skip, include_not_tagged_products=include_not_tagged_products, - template_url=self.list_by_tags.metadata['url'], + api_version=api_version, + template_url=self.list_by_tags.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -884,7 +1133,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -894,8 +1145,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags'} # type: ignore + list_by_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py index 2528cc49c4e75..35a7d4cf131a2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,300 +6,335 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, product_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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"], + policy_id: Union[str, _models.PolicyIdName], subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ProductPolicyOperations(object): - """ProductPolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 - ) -> "_models.PolicyCollection": + self, resource_group_name: str, service_name: 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyCollection] - 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, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,15 +342,14 @@ def list_by_product( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyCollection', pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies'} # type: ignore - + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies"} # type: ignore @distributed_trace def get_entity_tag( @@ -322,44 +357,57 @@ def get_entity_tag( resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -368,15 +416,13 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace def get( @@ -384,35 +430,43 @@ def get( resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the Product level. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, @@ -420,12 +474,18 @@ def get( policy_id=policy_id, subscription_id=self._config.subscription_id, format=format, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,17 +494,92 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PolicyContract', pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -452,41 +587,57 @@ def create_or_update( resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the Product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract", is_xml=True) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -494,15 +645,22 @@ def create_or_update( 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -512,59 +670,65 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('PolicyContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, product_id: str, - policy_id: Union[str, "_models.PolicyIdName"], + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str - :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -572,12 +736,18 @@ def delete( policy_id=policy_id, subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -588,5 +758,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # 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 index a8fb8cd3f6cb6..dfe898d6dbf73 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,62 +47,66 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ProductSubscriptionsOperations(object): - """ProductSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -104,15 +118,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionCollection"]: + ) -> Iterable["_models.SubscriptionContract"]: """Lists the collection of subscriptions to the specified product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + instance. Required. :type product_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -124,26 +138,35 @@ def list( 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionCollection or the result of + :return: An iterator like instance of either SubscriptionContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SubscriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -152,25 +175,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -184,7 +204,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,8 +216,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py index 4ac1e1a88bd60..b7e906099330f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,174 +6,186 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, quota_counter_key: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, quota_counter_key: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class QuotaByCounterKeysOperations(object): - """QuotaByCounterKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. :type quota_counter_key: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: QuotaCounterCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterCollection] - 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,15 +193,84 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -196,51 +278,75 @@ def update( resource_group_name: str, service_name: str, quota_counter_key: str, - parameters: "_models.QuotaCounterValueUpdateContract", + parameters: Union[_models.QuotaCounterValueUpdateContract, IO], **kwargs: Any - ) -> "_models.QuotaCounterCollection": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection - :raises: ~azure.core.exceptions.HttpResponseError + :return: QuotaCounterCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterCollection] - _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,12 +354,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py index 00621e347ba2f..fd374ecc606e0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,34 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -34,35 +42,41 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -71,116 +85,122 @@ def build_update_request( quota_counter_key: str, quota_period_key: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class QuotaByPeriodKeysOperations(object): - """QuotaByPeriodKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + :param quota_period_key: Quota period key identifier. Required. :type quota_period_key: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: QuotaCounterContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,55 +208,145 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterContract', pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # 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. - @distributed_trace + :param resource_group_name: The name of the resource group. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.QuotaCounterValueUpdateContract", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.QuotaCounterContract": + ) -> _models.QuotaCounterContract: """Updates an existing quota counter value in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + :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. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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], + **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. 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 model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: QuotaCounterContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QuotaCounterContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QuotaCounterValueUpdateContract") request = build_update_request( resource_group_name=resource_group_name, @@ -244,14 +354,21 @@ def update( 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, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -259,12 +376,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QuotaCounterContract', pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py index f31d8b3a042dd..3aa5d245e6bca 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,128 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class RegionOperations(object): - """RegionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.RegionListResult"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.RegionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -140,7 +158,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -150,8 +170,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py index 37cdf036be345..d5a6931ea49b5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,27 +7,36 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,40 +48,46 @@ def build_list_by_api_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_user_request( @@ -85,40 +101,46 @@ def build_list_by_user_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_operation_request( @@ -132,40 +154,46 @@ def build_list_by_operation_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_product_request( @@ -179,40 +207,46 @@ def build_list_by_product_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_geo_request( @@ -225,38 +259,44 @@ def build_list_by_geo_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( @@ -270,40 +310,46 @@ def build_list_by_subscription_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_time_request( @@ -318,41 +364,47 @@ def build_list_by_time_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_request_request( @@ -365,60 +417,64 @@ def build_list_by_request_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ReportsOperations(object): - """ReportsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -430,34 +486,44 @@ def list_by_api( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable["_models.ReportRecordContract"]: """Lists report records by API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -466,25 +532,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -498,7 +561,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -508,11 +573,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi"} # type: ignore @distributed_trace def list_by_user( @@ -524,12 +587,12 @@ def list_by_user( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable["_models.ReportRecordContract"]: """Lists report records by User. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -544,26 +607,37 @@ def list_by_user(
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -572,25 +646,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_user.metadata['url'], + api_version=api_version, + template_url=self.list_by_user.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -604,7 +675,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -614,11 +687,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore + list_by_user.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser"} # type: ignore @distributed_trace def list_by_operation( @@ -630,12 +701,12 @@ def list_by_operation( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable["_models.ReportRecordContract"]: """Lists report records by API Operations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -650,26 +721,37 @@ def list_by_operation(
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -678,25 +760,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_operation.metadata['url'], + api_version=api_version, + template_url=self.list_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -710,7 +789,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -720,11 +801,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore + list_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation"} # type: ignore @distributed_trace def list_by_product( @@ -736,12 +815,12 @@ def list_by_product( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable["_models.ReportRecordContract"]: """Lists report records by Product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -755,26 +834,37 @@ def list_by_product(
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -783,25 +873,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -815,7 +902,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -825,11 +914,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct"} # type: ignore @distributed_trace def list_by_geo( @@ -840,12 +927,12 @@ def list_by_geo( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable["_models.ReportRecordContract"]: """Lists report records by geography. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -859,25 +946,35 @@ def list_by_geo( cacheMissCount | select | | |
| apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| - serviceTimeMax | select | | |
. + serviceTimeMax | select | | |
. Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -885,24 +982,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_geo.metadata['url'], + api_version=api_version, + template_url=self.list_by_geo.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -916,7 +1011,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -926,11 +1023,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore + list_by_geo.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo"} # type: ignore @distributed_trace def list_by_subscription( @@ -942,12 +1037,12 @@ def list_by_subscription( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable["_models.ReportRecordContract"]: """Lists report records by subscription. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -961,26 +1056,37 @@ def list_by_subscription( |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -989,25 +1095,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1021,7 +1124,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1031,11 +1136,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription"} # type: ignore @distributed_trace def list_by_time( @@ -1048,12 +1151,12 @@ def list_by_time( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable["_models.ReportRecordContract"]: """Lists report records by Time. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| timestamp | @@ -1066,32 +1169,42 @@ def list_by_time( cacheHitsCount | select | | |
| cacheMissCount | select | | |
| apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | - select | | |
| serviceTimeMax | select | | |
. + 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)). + TimeSpan(hours, minutes, seconds)). Required. :type interval: ~datetime.timedelta - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -1101,26 +1214,22 @@ def prepare_request(next_link=None): top=top, skip=skip, orderby=orderby, - template_url=self.list_by_time.metadata['url'], + api_version=api_version, + template_url=self.list_by_time.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1134,7 +1243,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1144,11 +1255,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore + list_by_time.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime"} # type: ignore @distributed_trace def list_by_request( @@ -1159,37 +1268,47 @@ def list_by_request( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.RequestReportCollection"]: + ) -> Iterable["_models.RequestReportRecordContract"]: """Lists report records by Request. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | |
. + filter | eq | |
| subscriptionId | filter | eq | |
. Required. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RequestReportCollection or the result of + :return: An iterator like instance of either RequestReportRecordContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.RequestReportCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RequestReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RequestReportCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -1197,24 +1316,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_request.metadata['url'], + api_version=api_version, + template_url=self.list_by_request.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1228,7 +1345,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1238,8 +1357,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_request.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest'} # type: ignore + list_by_request.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py index 5bd986e52e0dd..6b3bb2e64b89e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,246 +6,255 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class SignInSettingsOperations(object): - """SignInSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,51 +263,57 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalSigninSettings": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSigninSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSigninSettings] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,66 +322,150 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalSigninSettings', pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore + @overload + def update( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + if_match: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def update( + def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSigninSettings", + parameters: Union[_models.PortalSigninSettings, IO], **kwargs: Any ) -> None: """Update Sign-In settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update Sign-In settings. - :type parameters: ~api_management_client.models.PortalSigninSettings + :param parameters: Update Sign-In settings. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'PortalSigninSettings') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSigninSettings", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -376,57 +476,141 @@ def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PortalSigninSettings", + parameters: Union[_models.PortalSigninSettings, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSigninSettings": + ) -> _models.PortalSigninSettings: """Create or Update Sign-In settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSigninSettings + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSigninSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalSigninSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSigninSettings] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSigninSettings", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,12 +618,11 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSigninSettings', pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py index f5a8cb49bfc35..d690e81e5cf67 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,246 +6,255 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _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 = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any + resource_group_name: str, service_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class SignUpSettingsOperations(object): - """SignUpSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,51 +263,57 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - **kwargs: Any - ) -> "_models.PortalSignupSettings": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSignupSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSignupSettings] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,66 +322,150 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('PortalSignupSettings', pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore + @overload + def update( # pylint: disable=inconsistent-return-statements + 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + if_match: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def update( + def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSignupSettings", + parameters: Union[_models.PortalSignupSettings, IO], **kwargs: Any ) -> None: """Update Sign-Up settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update Sign-Up settings. - :type parameters: ~api_management_client.models.PortalSignupSettings + :param parameters: Update Sign-Up settings. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'PortalSignupSettings') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSignupSettings", is_xml=True) request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -376,57 +476,141 @@ def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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: "_models.PortalSignupSettings", + parameters: Union[_models.PortalSignupSettings, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSignupSettings": + ) -> _models.PortalSignupSettings: """Create or Update Sign-Up settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSignupSettings + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings - :raises: ~azure.core.exceptions.HttpResponseError + :return: PortalSignupSettings or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PortalSignupSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PortalSignupSettings] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PortalSignupSettings", is_xml=True) 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,12 +618,11 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PortalSignupSettings', pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py index 6a8d273c3c0c6..e08afa204c922 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,113 +46,123 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -152,53 +171,54 @@ def build_create_or_update_request( sid: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, notify: Optional[bool] = None, if_match: Optional[str] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -208,224 +228,229 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, notify: Optional[bool] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, sid: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class SubscriptionOperations(object): - """SubscriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -436,12 +461,12 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionCollection"]: + ) -> Iterable["_models.SubscriptionContract"]: """Lists all subscriptions of the API Management service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -453,26 +478,35 @@ def list( 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionCollection or the result of + :return: An iterator like instance of either SubscriptionContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SubscriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -480,24 +514,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -511,7 +543,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,53 +555,58 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -576,56 +615,61 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any - ) -> "_models.SubscriptionContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,17 +678,110 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -652,66 +789,90 @@ def create_or_update( resource_group_name: str, service_name: str, sid: str, - parameters: "_models.SubscriptionCreateParameters", + parameters: Union[_models.SubscriptionCreateParameters, IO], notify: Optional[bool] = None, if_match: Optional[str] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Creates or updates the subscription of specified user to the specified product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str - :param parameters: Create parameters. - :type parameters: ~api_management_client.models.SubscriptionCreateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or IO :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. + * 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. + 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. - :type app_type: str or ~api_management_client.models.AppType + 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. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] - _json = self._serialize.body(parameters, 'SubscriptionCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, - json=_json, notify=notify, if_match=if_match, app_type=app_type, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -721,22 +882,115 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -745,65 +999,89 @@ def update( service_name: str, sid: str, if_match: str, - parameters: "_models.SubscriptionUpdateParameters", + parameters: Union[_models.SubscriptionUpdateParameters, IO], notify: Optional[bool] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Updates the details of a subscription specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.SubscriptionUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or IO :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. + * 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. - :type app_type: str or ~api_management_client.models.AppType + 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. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SubscriptionUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, - json=_json, notify=notify, app_type=app_type, - template_url=self.update.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -812,63 +1090,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - sid: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -879,49 +1164,57 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace - def regenerate_primary_key( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.regenerate_primary_key.metadata['url'], + api_version=api_version, + template_url=self.regenerate_primary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -932,49 +1225,57 @@ def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey'} # type: ignore - + regenerate_primary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey"} # type: ignore @distributed_trace - def regenerate_secondary_key( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.regenerate_secondary_key.metadata['url'], + api_version=api_version, + template_url=self.regenerate_secondary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -985,49 +1286,57 @@ def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey'} # type: ignore - + regenerate_secondary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey"} # type: ignore @distributed_trace def list_secrets( - self, - resource_group_name: str, - service_name: str, - sid: str, - **kwargs: Any - ) -> "_models.SubscriptionKeysContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionKeysContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionKeysContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionKeysContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionKeysContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, - template_url=self.list_secrets.metadata['url'], + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1036,14 +1345,13 @@ def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionKeysContract', pipeline_response) + deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py index 963a0651f991c..7053eaa04281d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -39,41 +48,47 @@ def build_list_by_operation_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_state_by_operation_request( @@ -85,36 +100,42 @@ def build_get_entity_state_by_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_operation_request( @@ -126,36 +147,42 @@ def build_get_by_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_assign_to_operation_request( @@ -167,36 +194,42 @@ def build_assign_to_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_detach_from_operation_request( @@ -208,36 +241,42 @@ def build_detach_from_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_api_request( @@ -251,196 +290,206 @@ def build_list_by_api_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, api_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_product_request( @@ -454,196 +503,206 @@ def build_list_by_product_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_entity_state_by_product_request( - resource_group_name: str, - service_name: str, - product_id: str, - tag_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, service_name: str, product_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, product_id: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_service_request( @@ -657,115 +716,125 @@ def build_list_by_service_request( scope: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if scope is not None: - query_parameters['scope'] = _SERIALIZER.query("scope", scope, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["scope"] = _SERIALIZER.query("scope", scope, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, tag_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -774,157 +843,151 @@ def build_create_or_update_request( tag_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, tag_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, tag_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class TagOperations(object): - """TagOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -937,41 +1000,51 @@ def list_by_operation( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable["_models.TagContract"]: """Lists all Tags associated with the Operation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -981,26 +1054,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_operation.metadata['url'], + api_version=api_version, + template_url=self.list_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,7 +1083,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1024,48 +1095,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags'} # type: ignore + list_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_state_by_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -1073,12 +1144,18 @@ def get_entity_state_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.get_entity_state_by_operation.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1087,52 +1164,52 @@ def get_entity_state_by_operation( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + get_entity_state_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - request = build_get_by_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -1140,12 +1217,18 @@ def get_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.get_by_operation.metadata['url'], + api_version=api_version, + template_url=self.get_by_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1154,54 +1237,55 @@ def get_by_operation( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + get_by_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - request = build_assign_to_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -1209,12 +1293,18 @@ def assign_to_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.assign_to_operation.metadata['url'], + api_version=api_version, + template_url=self.assign_to_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1223,55 +1313,56 @@ def assign_to_operation( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - assign_to_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + assign_to_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace - def detach_from_operation( - self, - resource_group_name: str, - service_name: str, - api_id: str, - operation_id: str, - tag_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_detach_from_operation_request( resource_group_name=resource_group_name, service_name=service_name, @@ -1279,12 +1370,18 @@ def detach_from_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.detach_from_operation.metadata['url'], + api_version=api_version, + template_url=self.detach_from_operation.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1295,8 +1392,7 @@ def detach_from_operation( if cls: return cls(pipeline_response, None, {}) - detach_from_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore - + detach_from_operation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace def list_by_api( @@ -1308,38 +1404,48 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable["_models.TagContract"]: """Lists all Tags associated with the API. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -1348,25 +1454,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_api.metadata['url'], + api_version=api_version, + template_url=self.list_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1380,7 +1483,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1390,56 +1495,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags'} # type: ignore + list_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_state_by_api.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1448,60 +1560,67 @@ def get_entity_state_by_api( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + get_entity_state_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace def get_by_api( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_id: str, - **kwargs: Any - ) -> "_models.TagContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.get_by_api.metadata['url'], + api_version=api_version, + template_url=self.get_by_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1510,62 +1629,70 @@ def get_by_api( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + get_by_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.assign_to_api.metadata['url'], + api_version=api_version, + template_url=self.assign_to_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1575,67 +1702,75 @@ def assign_to_api( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - assign_to_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + assign_to_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace - def detach_from_api( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.detach_from_api.metadata['url'], + api_version=api_version, + template_url=self.detach_from_api.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1646,8 +1781,7 @@ def detach_from_api( if cls: return cls(pipeline_response, None, {}) - detach_from_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore - + detach_from_api.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace def list_by_product( @@ -1659,38 +1793,48 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable["_models.TagContract"]: """Lists all Tags associated with the Product. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 |
. + 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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -1699,25 +1843,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_product.metadata['url'], + api_version=api_version, + template_url=self.list_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1731,7 +1872,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1741,56 +1884,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags'} # type: ignore + list_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags"} # 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 + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_state_by_product.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1799,60 +1949,67 @@ def get_entity_state_by_product( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + get_entity_state_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace def get_by_product( - self, - resource_group_name: str, - service_name: str, - product_id: str, - tag_id: str, - **kwargs: Any - ) -> "_models.TagContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.get_by_product.metadata['url'], + api_version=api_version, + template_url=self.get_by_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1861,62 +2018,70 @@ def get_by_product( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + get_by_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - 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, - template_url=self.assign_to_product.metadata['url'], + api_version=api_version, + template_url=self.assign_to_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1925,63 +2090,71 @@ def assign_to_product( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - assign_to_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + assign_to_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace - def detach_from_product( - self, - resource_group_name: str, - service_name: str, - product_id: str, - tag_id: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.detach_from_product.metadata['url'], + api_version=api_version, + template_url=self.detach_from_product.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1992,8 +2165,7 @@ def detach_from_product( if cls: return cls(pipeline_response, None, {}) - detach_from_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore - + detach_from_product.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace def list_by_service( @@ -2005,38 +2177,47 @@ def list_by_service( skip: Optional[int] = None, scope: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable["_models.TagContract"]: """Lists a collection of tags defined within a service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -2045,25 +2226,22 @@ def prepare_request(next_link=None): top=top, skip=skip, scope=scope, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2077,7 +2255,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2087,51 +2267,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags"} # type: ignore @distributed_trace - def get_entity_state( - self, - resource_group_name: str, - service_name: str, - tag_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_state.metadata['url'], + api_version=api_version, + template_url=self.get_entity_state.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2140,55 +2326,61 @@ def get_entity_state( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore - + get_entity_state.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - tag_id: str, - **kwargs: Any - ) -> "_models.TagContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2197,17 +2389,86 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :param if_match: ETag of the Entity. Not required when creating an entity, but 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -2215,52 +2476,76 @@ def create_or_update( resource_group_name: str, service_name: str, tag_id: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: Union[_models.TagCreateUpdateParameters, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Creates a tag. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :param parameters: Create parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2270,22 +2555,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('TagContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -2294,51 +2648,75 @@ def update( service_name: str, tag_id: str, if_match: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: Union[_models.TagCreateUpdateParameters, IO], **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Updates the details of the tag specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagContract] - _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2347,62 +2725,70 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TagContract', pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - service_name: str, - tag_id: str, - if_match: str, - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2413,5 +2799,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py index 2d7cae70b46c2..525bc6b492fe4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -36,61 +46,65 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class TagResourceOperations(object): - """TagResourceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -101,12 +115,12 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable["_models.TagResourceContract"]: """Lists a collection of resources associated with tags. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| aid | @@ -122,26 +136,34 @@ def list_by_service( 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 | |
. + | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagResourceCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagResourceCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -149,24 +171,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -180,7 +200,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,8 +212,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py index b9ffd2f72bca6..50c2c46f36aa4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,160 +6,188 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, - access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class TenantAccessGitOperations(object): - """TenantAccessGitOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, "_models.AccessIdName"], - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_primary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_primary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_primary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -169,48 +198,57 @@ def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey'} # type: ignore - + regenerate_primary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey"} # type: ignore @distributed_trace - def regenerate_secondary_key( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, "_models.AccessIdName"], - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_secondary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_secondary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_secondary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -221,5 +259,4 @@ def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey'} # type: ignore - + regenerate_secondary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey"} # 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 index 67212b4c81136..5bab8a9f271c3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,420 +6,465 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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"], + access_name: Union[str, _models.AccessIdName], subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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"], + access_name: Union[str, _models.AccessIdName], subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class TenantAccessOperations(object): - """TenantAccessOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.AccessInformationCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param filter: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessInformationCollection or the result of + :return: An iterator like instance of either AccessInformationContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.AccessInformationCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AccessInformationContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -432,7 +478,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,51 +490,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant"} # type: ignore @distributed_trace def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, "_models.AccessIdName"], - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.get_entity_tag.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -495,55 +551,63 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, "_models.AccessIdName"], - **kwargs: Any - ) -> "_models.AccessInformationContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -552,70 +616,164 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationContract', pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information details. + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + access_name: Union[str, _models.AccessIdName], if_match: str, - parameters: "_models.AccessInformationCreateParameters", + parameters: Union[_models.AccessInformationCreateParameters, IO], **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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. + 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. - :type parameters: ~api_management_client.models.AccessInformationCreateParameters + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationContract] - _json = self._serialize.body(parameters, 'AccessInformationCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -624,70 +782,164 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationContract', pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information details. + + :param resource_group_name: The name of the resource group. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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"], + access_name: Union[str, _models.AccessIdName], if_match: str, - parameters: "_models.AccessInformationUpdateParameters", + parameters: Union[_models.AccessInformationUpdateParameters, IO], **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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. + 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. - :type parameters: ~api_management_client.models.AccessInformationUpdateParameters + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationContract] - _json = self._serialize.body(parameters, 'AccessInformationUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,57 +948,66 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationContract', pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace - def regenerate_primary_key( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, "_models.AccessIdName"], - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_primary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_primary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_primary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -757,48 +1018,57 @@ def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey'} # type: ignore - + regenerate_primary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey"} # type: ignore @distributed_trace - def regenerate_secondary_key( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, "_models.AccessIdName"], - **kwargs: Any + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_regenerate_secondary_key_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.regenerate_secondary_key.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_secondary_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -809,48 +1079,57 @@ def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey'} # type: ignore - + regenerate_secondary_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey"} # 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": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :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 :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessInformationSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationSecretsContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: AccessInformationSecretsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationSecretsContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessInformationSecretsContract] - request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, access_name=access_name, - template_url=self.list_secrets.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -859,14 +1138,13 @@ def list_secrets( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('AccessInformationSecretsContract', pipeline_response) + deserialized = self._deserialize("AccessInformationSecretsContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets'} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py index bf95e864c0f7a..3fa51e080a2db 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,294 +6,410 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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_initial( + +def build_deploy_request( resource_group_name: str, service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], subscription_id: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_save_request_initial( +def build_save_request( resource_group_name: str, service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], subscription_id: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_validate_request_initial( +def build_validate_request( resource_group_name: str, service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], subscription_id: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - configuration_name: Union[str, "_models.ConfigurationIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class TenantConfigurationOperations(object): - """TenantConfigurationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResultContract]] - _json = self._serialize.body(parameters, 'DeployConfigurationParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeployConfigurationParameters") - request = build_deploy_request_initial( + request = build_deploy_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._deploy_initial.metadata['url'], + content=_content, + template_url=self._deploy_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _deploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + _deploy_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> LROPoller["_models.OperationResultContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName - :param parameters: Deploy Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -303,121 +420,232 @@ def begin_deploy( Retry-After header is present. :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.OperationResultContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._deploy_initial( + raw_result = self._deploy_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_deploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + begin_deploy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # type: ignore def _save_initial( self, resource_group_name: str, service_name: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.SaveConfigurationParameter", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, IO], **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SaveConfigurationParameter') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResultContract]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SaveConfigurationParameter") - request = build_save_request_initial( + request = build_save_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._save_initial.metadata['url'], + content=_content, + template_url=self._save_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _save_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + _save_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.SaveConfigurationParameter", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, IO], **kwargs: Any - ) -> LROPoller["_models.OperationResultContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName - :param parameters: Save Configuration parameters. - :type parameters: ~api_management_client.models.SaveConfigurationParameter + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -428,121 +656,232 @@ def begin_save( Retry-After header is present. :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.OperationResultContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._save_initial( + raw_result = self._save_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_save.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + begin_save.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResultContract]] - _json = self._serialize.body(parameters, 'DeployConfigurationParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeployConfigurationParameters") - request = build_validate_request_initial( + request = build_validate_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :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: "_models.DeployConfigurationParameters", + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, IO], **kwargs: Any - ) -> LROPoller["_models.OperationResultContract"]: + ) -> 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName - :param parameters: Validate Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -553,92 +892,112 @@ def begin_validate( Retry-After header is present. :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.OperationResultContract] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_initial( + raw_result = self._validate_initial( # type: ignore 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResultContract', pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # type: ignore @distributed_trace def get_sync_state( self, resource_group_name: str, service_name: str, - configuration_name: Union[str, "_models.ConfigurationIdName"], + configuration_name: Union[str, _models.ConfigurationIdName], **kwargs: Any - ) -> "_models.TenantConfigurationSyncStateContract": + ) -> _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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :param configuration_name: The identifier of the Git Configuration Operation. "configuration" + Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantConfigurationSyncStateContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantConfigurationSyncStateContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TenantConfigurationSyncStateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantConfigurationSyncStateContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantConfigurationSyncStateContract] - request = build_get_sync_state_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, configuration_name=configuration_name, - template_url=self.get_sync_state.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_sync_state.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -646,12 +1005,11 @@ def get_sync_state( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TenantConfigurationSyncStateContract', pipeline_response) + deserialized = self._deserialize("TenantConfigurationSyncStateContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_sync_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState'} # type: ignore - + get_sync_state.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py index 240f808226a3a..aad68f494267e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,175 +6,194 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - settings_type: Union[str, "_models.SettingsTypeName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "settingsType": _SERIALIZER.url("settings_type", settings_type, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class TenantSettingsOperations(object): - """TenantSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.TenantSettingsCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param filter: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantSettingsCollection or the result of + :return: An iterator like instance of either TenantSettingsContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TenantSettingsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantSettingsCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -187,7 +207,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -197,51 +219,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings"} # type: ignore @distributed_trace def get( self, resource_group_name: str, service_name: str, - settings_type: Union[str, "_models.SettingsTypeName"], + settings_type: Union[str, _models.SettingsTypeName], **kwargs: Any - ) -> "_models.TenantSettingsContract": + ) -> _models.TenantSettingsContract: """Get tenant settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str - :param settings_type: The identifier of the settings. - :type settings_type: str or ~api_management_client.models.SettingsTypeName + :param settings_type: The identifier of the settings. "public" Required. + :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantSettingsContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantSettingsContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: TenantSettingsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantSettingsContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, - subscription_id=self._config.subscription_id, settings_type=settings_type, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -250,14 +283,13 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('TenantSettingsContract', pipeline_response) + deserialized = self._deserialize("TenantSettingsContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py index 2855d8e39ae5c..98b4057ad1743 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,132 +6,159 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class UserConfirmationPasswordOperations(object): - """UserConfirmationPasswordOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( + 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, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> None: """Sends confirmation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type app_type: str or ~api_management_client.models.AppType + 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 callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.send.metadata['url'], + api_version=api_version, + template_url=self.send.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: @@ -141,5 +169,4 @@ def send( if cls: return cls(pipeline_response, None, {}) - send.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send'} # type: ignore - + send.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send"} # 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 index 258e61fc4721f..36a337f4a2a78 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,62 +47,66 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class UserGroupOperations(object): - """UserGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -104,14 +118,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GroupCollection"]: + ) -> Iterable["_models.GroupContract"]: """Lists all user groups. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 @@ -119,25 +134,34 @@ def list( 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 |
. + endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GroupCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -146,25 +170,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -178,7 +199,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,8 +211,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py index 6b528b83a6bc5..33860ca2c538f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,136 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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 + resource_group_name: str, service_name: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class UserIdentitiesOperations(object): - """UserIdentitiesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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.UserIdentityCollection"]: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserIdentityCollection or the result of + :return: An iterator like instance of either UserIdentityContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.UserIdentityCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserIdentityContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserIdentityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserIdentityCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -148,7 +164,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -158,8 +176,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py index 5a8c2937b9a49..19e6be0b5fb27 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,28 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -38,115 +47,125 @@ def build_list_by_service_request( expand_groups: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) if expand_groups is not None: - query_parameters['expandGroups'] = _SERIALIZER.query("expand_groups", expand_groups, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["expandGroups"] = _SERIALIZER.query("expand_groups", expand_groups, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -155,98 +174,94 @@ def build_create_or_update_request( user_id: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, notify: Optional[bool] = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + 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, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, user_id: str, subscription_id: str, *, if_match: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -258,149 +273,151 @@ def build_delete_request( if_match: str, delete_subscriptions: Optional[bool] = None, notify: Optional[bool] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, 'bool') + _params["deleteSubscriptions"] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, "bool") if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, service_name: str, user_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class UserOperations(object): - """UserOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -412,12 +429,12 @@ def list_by_service( skip: Optional[int] = None, expand_groups: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.UserCollection"]: + ) -> Iterable["_models.UserContract"]: """Lists a collection of registered users in the specified service instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :param service_name: The name of the API Management service. Required. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | @@ -427,27 +444,36 @@ def list_by_service( |
| 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 | | |
. + |
| groups | expand | | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param expand_groups: Detailed Group in response. + :param expand_groups: Detailed Group in response. Default value is None. :type expand_groups: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.UserCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -456,25 +482,22 @@ def prepare_request(next_link=None): top=top, skip=skip, expand_groups=expand_groups, - template_url=self.list_by_service.metadata['url'], + api_version=api_version, + template_url=self.list_by_service.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -488,7 +511,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -498,51 +523,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users'} # type: ignore + list_by_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users"} # type: ignore @distributed_trace - def get_entity_tag( - self, - resource_group_name: str, - service_name: str, - user_id: str, - **kwargs: Any - ) -> bool: + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.get_entity_tag.metadata['url'], + api_version=api_version, + template_url=self.get_entity_tag.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -551,55 +582,61 @@ def get_entity_tag( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) if cls: return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore - + get_entity_tag.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - service_name: str, - user_id: str, - **kwargs: Any - ) -> "_models.UserContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] - request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -608,17 +645,92 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + 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. 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 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -626,56 +738,80 @@ def create_or_update( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserCreateParameters", + parameters: Union[_models.UserCreateParameters, IO], notify: Optional[bool] = None, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Creates or Updates a user. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.UserCreateParameters - :param notify: Send an Email notification to the User. + :param parameters: Create or update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters or IO + :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. + updating an entity. Default value is None. :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] - _json = self._serialize.body(parameters, 'UserCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, - json=_json, notify=notify, if_match=if_match, - template_url=self.create_or_update.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -685,22 +821,91 @@ def create_or_update( response_headers = {} if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('UserContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("UserContract", pipeline_response) if response.status_code == 201: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - - deserialized = self._deserialize('UserContract', pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -709,51 +914,75 @@ def update( service_name: str, user_id: str, if_match: str, - parameters: "_models.UserUpdateParameters", + parameters: Union[_models.UserUpdateParameters, IO], **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Updates the details of the user specified by its identifier. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + response of the GET request or it should be * for unconditional update. Required. :type if_match: str - :param parameters: Update parameters. - :type parameters: ~api_management_client.models.UserUpdateParameters + :param parameters: Update parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserContract] - _json = self._serialize.body(parameters, 'UserUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - content_type=content_type, if_match=if_match, + api_version=api_version, + content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -762,20 +991,19 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('UserContract', pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -783,39 +1011,49 @@ def delete( if_match: str, delete_subscriptions: Optional[bool] = None, notify: Optional[bool] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, + app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any ) -> None: """Deletes specific user. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + 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. + :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. + :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. - :type app_type: str or ~api_management_client.models.AppType + 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 callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, service_name=service_name, @@ -825,12 +1063,18 @@ def delete( delete_subscriptions=delete_subscriptions, notify=notify, app_type=app_type, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -841,49 +1085,58 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace def generate_sso_url( - self, - resource_group_name: str, - service_name: str, - user_id: str, - **kwargs: Any - ) -> "_models.GenerateSsoUrlResult": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 callable cls: A custom type or function that will be passed the direct response - :return: GenerateSsoUrlResult, or the result of cls(response) - :rtype: ~api_management_client.models.GenerateSsoUrlResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: GenerateSsoUrlResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateSsoUrlResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenerateSsoUrlResult] - 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, - template_url=self.generate_sso_url.metadata['url'], + api_version=api_version, + template_url=self.generate_sso_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -891,15 +1144,76 @@ def generate_sso_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateSsoUrlResult', pipeline_response) + deserialized = self._deserialize("GenerateSsoUrlResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_sso_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl'} # type: ignore + generate_sso_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl"} # 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. 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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( @@ -907,47 +1221,72 @@ def get_shared_access_token( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserTokenParameters", + parameters: Union[_models.UserTokenParameters, IO], **kwargs: Any - ) -> "_models.UserTokenResult": + ) -> _models.UserTokenResult: """Gets the Shared Access Authorization Token for the User. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. - :type parameters: ~api_management_client.models.UserTokenParameters + :param parameters: Create Authorization Token parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.UserTokenResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserTokenResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserTokenResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserTokenResult] - _json = self._serialize.body(parameters, 'UserTokenParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, 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, - template_url=self.get_shared_access_token.metadata['url'], + content=_content, + template_url=self.get_shared_access_token.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -955,12 +1294,11 @@ def get_shared_access_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UserTokenResult', pipeline_response) + deserialized = self._deserialize("UserTokenResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_shared_access_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token'} # type: ignore - + get_shared_access_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py index 804a840b64056..ecb93ceb2a1ec 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,36 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.pipeline.transport import HttpResponse from azure.core.rest import 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 msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from .._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +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, @@ -37,101 +47,106 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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') + _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'), - "serviceName": _SERIALIZER.url("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'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + 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 + resource_group_name: str, service_name: str, user_id: str, sid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: str + 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}') + _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'), - "serviceName": _SERIALIZER.url("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, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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])?$", + ), + "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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class UserSubscriptionOperations(object): - """UserSubscriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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( @@ -143,14 +158,15 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionCollection"]: + ) -> Iterable["_models.SubscriptionContract"]: """Lists the collection of subscriptions of the specified user. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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 | @@ -161,26 +177,35 @@ def list( 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 |
. + contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionCollection or the result of + :return: An iterator like instance of either SubscriptionContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SubscriptionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionCollection] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, @@ -189,25 +214,22 @@ def prepare_request(next_link=None): filter=filter, top=top, skip=skip, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -221,7 +243,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -231,56 +255,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - service_name: str, - user_id: str, - sid: str, - **kwargs: Any - ) -> "_models.SubscriptionContract": + 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. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param service_name: The name of the API Management service. + :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. + user and a product in API Management. Required. :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract - :raises: ~azure.core.exceptions.HttpResponseError + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionContract] - 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, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -289,14 +320,13 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('SubscriptionContract', pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}"} # type: ignore